When applying the above plugin I’m getting the error: `A problem occurred configuring root project '...
a
When applying the above plugin I’m getting the error:
A problem occurred configuring root project ''.
> 'kotlin-android' plugin requires one of the Android Gradle plugins.
Please apply one of the following plugins to ':' project:
- com.android.application
- com.android.library
- com.android.dynamic-feature
- com.android.asset-pack
- com.android.asset-pack-bundle
- com.android.lint
- com.android.test
- com.android.instantapp
- com.android.feature
What am I missing?
m
You're most likely applying the kotlin-android plugin in the root project instead of
app
a
That’s right
doing it on the app gives me:
Plugin request for plugin already on the classpath must not include a version
But Google recommends supplying the plugin
sorry for the loaded question. I hope you understand my concern @mbonnin
m
Oh yea I 💯 understand, I've been there 😅
In the
app
module, do
Copy code
plugins {
    id 'org.jetbrains.kotlin.android' 
}
a
dropping the version gives me
An exception occurred applying plugin request [id: ‘org.jetbrains.kotlin.android’]
Failed to apply plugin ‘org.jetbrains.kotlin.android’.
> Extension with name ‘android’ does not exist. Currently registered extension names: [ext, kotlin, kotlinTestRegistry]
m
Make sure to add kotlin after android
Copy code
plugins {
    id 'com.android.application' 
    id 'org.jetbrains.kotlin.android' 
}
💯 1
a
This worked @mbonnin!
🎉 2
The thing i didn’t understand is: Plugin request for plugin already on the classpath must not include a version
when I include the version
why?
m
Because there would be a conflict between the version you declare in the root
classpath
and the one in the app
plugins {}
You can read https://dev.to/autonomousapps/a-crash-course-in-classpaths-build-l08 for insigths about Gradle classloaders
👍 1
And https://docs.gradle.org/current/userguide/plugins.html#sec:plugin_markers for the difference between artifacts, pluginId and pluginMarkers
a
Okay thanks a lot @mbonnin
m
Sure thing!
2420 Views