kotlin grdle8.x需要注意的语法变动

2023-12-22  本文已影响0人  赵宇_阿特奇

升级新版Android Studio和Gradle version8.0 后发现maven报错:

1.Unexpected tokens (use ';' to separate expressions on the same line)

image image

解决:新版写法发生了改变:

maven
maven { url = uri("https://jitpack.io") }
ndk
ndk {
    abiFilters.add("arm64-v8a")
    abiFilters.add("armeabi-v7a")
}
本地module
implementation(project(":xxxLib"))
远程依赖
implementation("com.google.dagger:hilt-android:2.44")
productFlavors
productFlavors {
    //开发api地址
    create("dev") {

    }

    //产品api地址
    create("product") {

    }
}
signingConfigs
signingConfigs {
        val alias = "xxx"
        val password = "xxx"
        val filePath = "keys/android.keystore"  //签名文件路径 如:../faceprint.jks
        create("signingRelease") {
            keyAlias = alias
            keyPassword = password
            storeFile = file(filePath)
            storePassword = password
    }
}

2.报错:Product Flavor 'xxxx' contains custom BuildConfig fields, but the feature is disabled.

项目中使用productFlavors配置了buildConfigField 提示功能禁用
解决办法:开启buildConfig

buildFeatures {
    buildConfig = true
}
上一篇下一篇

猜你喜欢

热点阅读