This message was deleted.
# community-support
s
This message was deleted.
c
org.gradle.api.GradleException: Error resolving plugin [id: 'org.jetbrains.kotlin.android', version: '1.8.21', apply: false]
My understanding is if you want to have a convention that configures android aspects of a project (or kotlin ones in kotlin-jvm modules), you need to import the plugins (?) as dependencies on your
buildSrc
module, so that you can expose the APIs used by the actual module build.gradle.kts files in your convention file.
v
Where do you have the
id("org.jetbrains.kotlin.android") version "1.8.21" apply false
?
c
So for example, I want to configure
Copy code
android {
   testOptions {
      unitTests.all { isIncludeResources = true }
   }
}
For example, in a
android-conventions.gradle.kts
file. android won't resolve unless the android gradle plugin is added as a dependency to the buildSrc module. Is this correct or am I way off base?
my toplevel
build.gradle.kts
file
Copy code
...
plugins {
    alias(libs.plugins.androidApplication) apply false
    alias(libs.plugins.kotlinAndroid) apply false
    alias(libs.plugins.androidLibrary) apply false
    alias(libs.plugins.dokka) apply false
    alias(libs.plugins.kotlin.jvm) apply false
}
...
v
my toplevel
build.gradle.kts
file
toplevel of what?
The actual production build?
c
oh so like
Copy code
project/
   buildSrc/
   moduleA/
   moduleB/
   build.gradle.kts <-- here
v
Ok, doesn't make too much sense to have it there at all, if you also have it as
implementation
dependency of your convention plugin in
buildSrc/build.gradle.kts
. You should remove those unless you have a concrete reason to add them which usually are just edge cases.
c
so adding them as a dependency to the buildSrc module is the same as applying them as a plugin?
v
That
android
does not resolve in your
android-conventions.gradle.kts
is because you only get type-safe accessors for plugins you applied in that same script in its
plugins { ... }
block
so adding them as a dependency to the buildSrc module is the same as applying them as a plugin?
No, and what you showed also does not apply them, mind the "apply false".
alias(libs.plugins.kotlin.jvm) apply false
does not apply anything, it just adds the plugin to the classpath
And having it as
implementation
dependency of your convention plugin has the same effect, if you actually apply that convention plugin
That the repo you linked to is using
alias(...) apply false
is probably just a bad example
c
story of my life! I guess I should read some documentation and understand what all this is doing in a bit more detail. I might have to let the paint dry a little with this conventions stuff I suppose
v
You could have a look at https://github.com/jjohannes/idiomatic-gradle, that should usually follow better practices. Though it might be a bit too much abstraction at places for a small to average build.
c
Cheers @Vampire I'll check it out
out of interest, what should I have said instead of
toplevel build.gradle.kts file
? Root project build.gradle.kts? I guess that's what gradle would refer to it as 🤔
v
I would have asked the same question. People sometimes tend to be imprecise with terminology and so I tend to ask for clarification to not waste time with wrong advices. 🙂 In both cases you could have meant top-level or root project of the build logic / buildSrc build, or of the production build. So in words "root project build script of the production build" would for example be clear if that is really what is meant too. 😄 Clearest is really showing the structure you talk about and then using the path or a pointer like you did in response to my question. 🙂
I just generally try to rule-out simple things and misunderstandings first as that often either clarifies things or already solves the problem 🙂
c
100% understand, I was just worried I might have missed some standard parlance somewhere! Cheers again @Vampire!
👌 1