Hi! Does anyone have any idea where to apply this ...
# gradle
d
Hi! Does anyone have any idea where to apply this comment: https://github.com/gradle/gradle/issues/20084#issuecomment-1060822638? I'm facing the same error, and I tried using that in my root module, app module, buildSrc convention plugin, but I still keep on getting the same error...
I tried using the pluginId w/o the version everywhere and it seems to work... but where is gradle pulling the version from then?
j
Avoid using
alias
and do
get()
from the
libs…
and pick the
id
. Apply it using
id(libs…)
I am mobile so I cannot share a better snippet, sorry
d
Where do the versions of those plugins come from then 🤔?
j
if you are doing implementation in buildSrc it will be picked from there
d
But I don't specify the version there either...
j
share what are you doing
d
root:
Copy code
plugins {
    id(libs.plugins.kotlin.jvm.get().pluginId) apply false
    id(libs.plugins.android.application.get().pluginId) apply false
//    alias(libs.plugins.android.library) apply false
//    alias(libs.plugins.android.test) apply false
    alias(libs.plugins.firebase.crashlytics) apply false
    alias(libs.plugins.firebase.perf) apply false
    alias(libs.plugins.gms) apply false
    id(libs.plugins.ksp.get().pluginId) apply false
    id(libs.plugins.hilt.get().pluginId) apply false
}
Copy code
class AndroidAppPlugin : Plugin<Project> {
    override fun apply(target: Project) {
        with(target) {
            val libs = the<LibrariesForLibs>()
            with(pluginManager) {
                apply("com.android.application")
                apply("org.jetbrains.kotlin.android")
                apply("dagger.hilt.android.plugin")
                apply("com.google.devtools.ksp")
            }
Copy code
class AndroidLibraryPlugin : Plugin<Project> {
    override fun apply(target: Project) {

        with(target) {
            val libs = the<LibrariesForLibs>()

            with(pluginManager) {
                apply("com.android.library")
                apply("org.jetbrains.kotlin.android")
                apply("dagger.hilt.android.plugin")
                apply("com.google.devtools.ksp")
            }
buildSrc build.gradle,.kts:
Copy code
dependencies {
    implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
    implementation("com.android.tools.build:gradle:" + libs.versions.agp.get())
    implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:" + libs.versions.kotlin.get())
j
which plugin has the problem?
d
Right now everything seems to build ok, but I don't seem to specify the versions anywhere (when I tried specifying it even in one of those places, then even the gradle sync for Android Studio failed ...)
So I'm wondering where the versions DO get resolved?
j
which plugin had the issue
d
Now I tried removing the version from the ksp plugin but got:
Copy code
org.gradle.api.plugins.UnknownPluginException: Plugin [id: 'com.google.devtools.ksp', apply: false] was not found in any of the following sources:

- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (plugin dependency must include a version number for this source)
	at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.resolveToFoundResult(DefaultPluginRequestApplicator.java:274)
	at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.lambda$resolvePluginRequests$3(DefaultPluginRequestApplicator.java:199)
	at org.gradle.util.internal.CollectionUtils.collect(CollectionUtils.java:212)
	at org.gradle.util.internal.CollectionUtils.collect(CollectionUtils.java:206)
	at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.resolvePluginRequests(DefaultPluginRequestApplicator.java:197)
	at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.resolvePluginRequests(DefaultPluginRequestApplicator.java:113)
	at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.applyPlugins(DefaultPluginRequestApplicator.java:102)
	at org.gradle.kotlin.dsl.provider.PluginRequestsHandler.handle(PluginRequestsHandler.kt:44)
	at org.gradle.kotlin.dsl.provider.StandardKotlinScriptEvaluator$InterpreterHost.applyPluginsTo(KotlinScriptEvaluator.kt:217)
	at org.gradle.kotlin.dsl.execution.Interpreter$ProgramHost.applyPluginsTo(Interpreter.kt:385)
Same with hilt... even though here they recommend that (I had exactly this problem...): https://github.com/google/dagger/issues/4048#issuecomment-1864237679 I'm really not understanding something here...
Wow, I think refreshVersions was my problem again... I forgot to comment out the Android plugin's version there... it could be that it caused different versions to be resolved in the project. I'm compiling now... 🤞🏼
Nope still not working 🤕
v
So I'm wondering where the versions DO get resolved?
Where you have
alias(libs.plugins...)
because the entry coming from the version catalog has the version
Aaaand, your question is off-topic. Please always consider channel and server topics on open communities, not only channel names. 😉
d
For android application plugin, I don't use
alias
anywhere... yeah, I wasn't sure if this was on-topic, things are sometimes a bit on the brink of Kotlin or not Kotlin... (and I have tried other communities in the past... they're not as friendly and helpful as here 😊... and it's not so nice to get answers in Groovy when you're writing Kotlin in Gradle scripts, IF they answer at all...)
v
I can guarantee you, that the Gradle slack that is also mentioned in the channel topic here is much more helpful than this here 🙂 And Kotlin DSL is the default DSL, so if someone gives an answer in Groovy DSL, tell them to get rid of that old shit. 😄
Maybe not so much for Android specific things as I'm not really into Android development. 😄
For android application plugin, I don't use
alias
anywhere
Well, hard to guess without seeing the actual build 🙂
Ah, no, no need to guess
In
buildSrc
you have an implementation dependency on AGP just as @Javier said already way up
image.png
j
When I used
buildSrc
I ended up adding all plugins as
implementation
there and the root project has no
apply false
plugins.
v
Yeah, that's pretty pointless then, just a no-op
135 Views