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"
    }
}
相关文章
相关标签/搜索