Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Kotlin DSL migration project gradle build

I am migrating to kotlin DSL

And this is my project level build gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
    id 'com.android.application' version '7.2.2' apply false
    id 'com.android.library' version '7.2.2' apply false
    id 'org.jetbrains.kotlin.android' version '1.7.10' apply false
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

I updated the file extension to –build.gradle.kts

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

And the file content to

plugins {
id ("com.android.application" version "7.2.2" apply false)
id ("com.android.library" version "7.2.2" apply false)
id ("org.jetbrains.kotlin.android" version "${Versions.kotlin}" apply false)
}

tasks.register("clean",Delete::class){
    delete(rootProject.buildDir)
}

I am getting this error

Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: 
public infix fun PluginDependencySpec.version(version: String?): PluginDependencySpec defined in org.gradle.kotlin.dsl
public infix fun PluginDependencySpec.version(version: Provider<String>): PluginDependencySpec defined in org.gradle.kotlin.dsl

>Solution :

Update the plugins block as follows:

plugins {
    id ("com.android.application") version "7.2.2" apply false
    id ("com.android.library") version "7.2.2" apply false
    id ("org.jetbrains.kotlin.android") version "${Versions.kotlin}" apply false
}

Also, I think the clean task is available by default. You do not need to create it manually.

You can also consider migrating to Version Catalog while you are migrating. Please follow the NowInAndroid app source code for that.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading