Gradle.kts Issue

I just upgraded my Android Studio IDE to Giraffe, and it appears that the gradle files from my old project need to change. Specifically, I am using the NDK and OpenCV with my project and these lines are no longer recognized and produce errors.

Error 1:

tasks.withType(JavaCompile) {
            compileTask -> compileTask.dependsOn ndkBuild          
    }

Error: “build.gradle.kts:50:58: Expecting an element”

It seems that the Lamba symbol is no longer functional.

Error 2:

For OpenCV I am receiving this error:

implementation project(":openCV45")
               ^ Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:
                  public val NamedDomainObjectContainer<Configuration>.implementation: NamedDomainObjectProvider<Configuration> defined in org.gradle.kotlin.dsl"

I do not understand what is causing these errors, if anyone can assist it would be greatly appreciated.

Thank you in advance.

The snippets you show are Groovy DSL, which would live in build.gradle.
The errors show that you use Kotlin DSL, which lives in build.gradle.kts.
You cannot simply copy Groovy DSL into a Kotlin DSL file, those are different languages.
https://docs.gradle.org/current/userguide/migrating_from_groovy_to_kotlin_dsl.html

Thank you for the guidance, and the shared link contained the solution to the issue. Greatly appreciate the assistance.

1 Like