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.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2023-06-08 02:28:51 +0000
Seen: 14 times
Last updated: Jun 08 '23
Why can't IntelliJ IDEA detect the Kotlin multiplatform library?
What is the correlation between coroutines and the Kotlin Gradle Plugin?
What are the typical approaches found in a Gradle build script?
Why isn't the date picker dialog displayed in an Android fragment using Kotlin in Android Studio?
What is the meaning of the error message "Task :react-native-gradle-plugin:compileKotlin FAILED"?
Is it necessary to have an updated Kotlin Gradle plugin for your project?
How can we avoid the duplication of Kotlin class jetified-kotlin-stdlib-1.8.10 in Android (Java)?
What is the process to integrate SQLiter in KMM for both Android and IOS?
Can a transitive dependency in gradle be made exclusively for runtime purposes?