Gradle sync failed: Cannot set the value of read-only property 'outputFile'

錯誤

Gradle sync failed: Cannot set the value of read-only property 'outputFile'

緣由

gradle打包,自定義apk名稱代碼報錯

解決

看不懂代碼就把原來的註釋了,本身再寫一個android

例如:app

// rename the apk with the version name
/*
applicationVariants.all { variant ->
    variant.outputs.each { output ->
        output.outputFile = new File(
                output.outputFile.parent + "/${variant.buildType.name}",
                "osc-android-${variant.versionName}-${variant.productFlavors[0].name}.apk".toLowerCase())
        
    }
}
*/
android.applicationVariants.all { variant ->
    variant.outputs.all {
        outputFileName = "oschain_${defaultConfig.versionName}.apk"
    }
}
相關文章
相關標籤/搜索