Does anyone know of any way I can refer to a versi...
# dependency-management
m
Does anyone know of any way I can refer to a version catalog in the plugins { } or buildscript.classpath { } blocks? I’m using gradle 7.0.2 and it keeps saying it can’t find the symbol for my version catalog. Android studio itself recognizes the symbols and can properly apply code completion, but gradle seems to not be able to evaluate the project. Code in thread
Copy code
buildscript {
	repositories() {
	     google()
	     mavenCentral()
	}
	dependencies {
		classpath("com.android.tools.build:gradle:${buildPlatform.versions.androidGradlePluginVersion}")
		classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${buildPlatform.versions.kotlinVersion}")
	}
}
Copy code
Line 7:               classpath("com.android.tools.build:gradle:${buildPlatform.versions.androidGradlePluginVersion}")
                                                        ^ Unresolved reference: buildPlatform
a
I recommend you try with 7.4. I believe in 7.0.2 that indeed was not yet supported, but it should be with 7.4 (I believe it also works with 7.3.3).
v
Indeed it works from 7.2 on. But I'd recommend not using the legacy approach to add plugins to the buildscript class path anyway, but using the
plugins
block instead.
There you can then also use a
plugins
entry from the version catalog if your Gradle version is recent enough