Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

When converting from build.gradle to build.gradle.kts, you need to pay attention to the syntax differences between the two.

To avoid the "Unresolved reference" error, make sure you update the syntax of the variable references to their Kotlin equivalent. For example, instead of using "artifactId" in build.gradle, use "project.artifactId" in build.gradle.kts.

Here's an example of the syntax difference:

build.gradle:

group = 'com.example'
version = '1.0.0'
archivesBaseName = 'my-app'

build.gradle.kts:

group = "com.example"
version = "1.0.0"
project.archivesBaseName.set("my-app")

Note that in build.gradle.kts, we're accessing the archivesBaseName property as a function call on the project object. This is because gradle.kts is more strongly typed than gradle and requires this additional syntax.

In general, make sure to check the Gradle documentation for the specific syntax changes when converting your build scripts.