Saturday, 17 September 2022

Can I define kotlinVer either plugins or dependencies when I use Android Studio?

I find there are two ways to define kotlin version in build.gradle (Project) based some sample projects, such as Code A and Code B.

Are they the same way? which one is better?

Code A

buildscript {
    ext {
        kotlinVer = '1.7.10'
        ...
    }
}

plugins {
     ...
    id 'org.jetbrains.kotlin.android' version "$kotlinVer" apply false
    
}

Code B

buildscript {
    ext {
       ...
    }

    repositories {
        google()
        mavenCentral()
    }

    dependencies {     
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10"
         ...
    }
}


from Can I define kotlinVer either plugins or dependencies when I use Android Studio?

No comments:

Post a Comment