1.Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated{apkData=Main{type=MAIN, fullName=debug, filters=[]}} of type com.android.build.gradle.internal.api.ApkVariantOutputImpl. Open File
解决方案:
- 使用 all() 替换 each()
- 使用 outputFileName 替换 output.outputFile
示例:
android.applicationVariants.all { variant ->
variant.outputs.each {
output ->
output.outputFile = new File(output.outputFile.parent, variant.name + "_" + variant.versionName + "_" + variant.versionCode + ".apk");
}
}
改为:
android.applicationVariants.all { variant ->
variant.outputs.all { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.apk')) {
def fileName = outputFile.name.replace("(output.outputFile.parent, variant.name",
"${variant.name}_${variant.versionName}_${variant.versionCode}")
outputFileName = fileName
}
}
}
2.Error:All flavors must now belong to a named flavor dimension. Learn more at https://d.android.com
解决方案:
在主app的build.gradle里面的
defaultConfig {
targetSdkVersion:***
minSdkVersion :***
versionCode:***
versionName :***
//版本名后面添加一句话,意思就是flavor dimension 它的维度就是该版本号,这样维度就是都是统一的了
flavorDimensions "versionCode"
3.style attribute '@android:attr/windowEnterAnimation' not found
解决方案:
关掉AAPT2即可
在Project/gradle.properties中添加 android.enableAapt2=false