Loading

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名称代码报错

解决

看不懂代码就把原来的注释了,自己再写一个

例如:

// 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"
    }
}
posted @ 2018-06-24 17:36  李帆1998  阅读(4277)  评论(0编辑  收藏  举报