I’m trying to define a gradle plugin in my toml fi...
# gradle
j
I’m trying to define a gradle plugin in my toml file like this
Copy code
[plugins]
kotlin-android = {id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
but I get the following error
Error resolving plugin [id: 'org.jetbrains.kotlin.android', version: '1.5.30']
when checking mvnrepository.com I can see it exists
implementation("org.jetbrains.kotlin.android:org.jetbrains.kotlin.android.gradle.plugin:1.5.30")
but I guess I’m not using the correct string in the
id
property?
j
looks like an issue in how is kotlin plugin created
Copy code
org.jetbrains.kotlin.android
v
Works fine here. I copied your definition, declared your version and applied it
j
Copy code
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.20-M1"
v
Then it complains that no Android plugin is applied
j
not sure why it is looking for "org.jetbrains.kotlin.androidorg.jetbrains.kotlin.android.gradle.plugin1.5.30"
v
So the plugin itself was found and is executed
What are you telling @Javier? That's the normal marker artifact that then depends on the actual artifact containing the JAR with the code like with almost any other plugin too.
@jean you need to provide the full error
j
Copy code
[versions]
kotlin = "1.5.30"
...
[plugins]
kotlin-android = {id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
then I try to use it like so
Copy code
plugins {
    alias(libs.plugins.kotlin.android)
    ...
}
and this is the error
f
You need to gradlePluginPortal() To your repositories
j
still the same error 😕
j
Works fine here In settings.gradle.kts
Copy code
pluginManagement {
    repositories {
        gradlePluginPortal()
        google()
        mavenCentral()
    }
}
j
the project I work on doesn’t have a
pluginManagement
block 🤔 let me see If I can add it
nop 😞
how did you declare the plugin in the toml file @Javi Chaqués?
j
I'm using AGP 7.1.1, Gradle 7.4 and Kotlion 1.6.10
My toml file:
Copy code
[plugins]

kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "plugin-kotlin" }
My settings.gradle.kts
Copy code
pluginManagement {
    repositories {
        gradlePluginPortal()
        google()
        mavenCentral()
    }
}

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        maven(url = "<https://jitpack.io>")
    }
}
i don't have buildscript in build.gradle.kts from root
app build.gradle.kts
Copy code
plugins {
    ...
    alias(libs.plugins.kotlin.android)
}
v
You still didn't provide the full error message, just the stack trace. Again, you need to provide the full error message.
Everything else is just guesswork as you see from the other answers.
j
I shared all I had from the Android Studio error window but I tried to update my kotlin version to 1.6.10 and realized the app was declaring a
classpath(…)
too that was apparently conflicting with it. After removing it the issue was gone 🤷 Thanks all of you for the help!
v
Android Studio probably suffers from the same usability problem still as IntelliJ regarding that: https://youtrack.jetbrains.com/issue/IDEA-226613
505 Views