第一個(gè)問題:
在項(xiàng)目的build.gradle文件里面
Cannot set the value of read-only property ‘outputFile’
Error:(56, 0) 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.
之前的代碼如下
applicationVariants.all { variant ->
? ? ? ? ? variant.outputs.each { output ->
???????????? if (output.outputFile != null && output.outputFile.name.endsWith('.apk')
???????????????? && 'release'.equals(variant.buildType.name)) {
???????????????? ? ? def apkFile = new File(
???????????????????????????? output.outputFile.getParent(),
???? ?? ???????????? "zh_${variant.flavorName}_v${variant.versionName}_${buildTime()}.apk")
???????????????????? output.outputFile = apkFile
??????? }
??? }
講之前的代碼注釋修改成如下即可傲武,貌似是命名改變了斜筐。
applicationVariants.all { variant ->
??????? /* variant.outputs.each { output ->
?????????? if (output.outputFile != null && output.outputFile.name.endsWith('.apk')
??????????????? && 'release'.equals(variant.buildType.name)) {
?????????????????????? def apkFile = new File(
????????????????? output.outputFile.getParent(),
??????????????? "zhemituan_${variant.flavorName}_v${variant.versionName}_${buildTime()}.apk")
????? output.outputFile = apkFile
?? }
}*/
variant.outputs.all {
outputFileName ="zh_${defaultConfig.versionName}"+"_${variant.productFlavors[0].name}.apk"
??? }
}
PS:另外就是記得在defaultConfig 下方加上這么一句話
flavorDimensions"versionCode"
第二個(gè)問題是:
compile ‘com.android.support:multidex:1.0.1’
若項(xiàng)目里面添加了此依賴详瑞,需要您將項(xiàng)目的build.gradle文件進(jìn)行修改动漾,也就是配置倉庫的地方
allprojects {
??? repositories {
????????????????? jcenter()
???????????????? maven { url"https://jitpack.io"}
???????????????? google()// 加入此行代碼---
???????? }
}
同時(shí)在module下的build.gradle處將之前的multidex的版本號(hào)升級(jí)到1.0.2
第三個(gè)問題:
Error:java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:Execution failed for task ‘:app:processDebugResources’.
Failed to execute aapt
Information:BUILD FAILED in 8s
這個(gè)問題我也是看了別人的博客才知道如何解決;
在項(xiàng)目的gradle.properties文件中底部加入
android.enableAapt2=false
第四個(gè)問題:
Annotation processors must be explicitly declared now. The following dependenciesonthecompile classpath are foundtocontainannotation processor. Please add themtotheannotationProcessor configuration. - butterknife-7.0.1.jar Alternatively,setandroid.defaultConfig.javaCompileOptions.annotationProcessorOptions.includeCompileClasspath =truetocontinuewithprevious behavior. Notethatthis optionisdeprecatedandwill be removedinthefuture.
使用了黃油刀出現(xiàn)的問題渠脉,compile'com.jakewharton:butterknife:7.0.1'
在module下的build.gradle中添加如下配置即可
android {
...defaultConfig {
...
?? ? ? ? ? javaCompileOptions {
???????? annotationProcessorOptions {
????????? includeCompileClasspath = true }
????????? }
??? }
}
第五個(gè)問題:
升級(jí)gradle了存皂,之前項(xiàng)目用的是25.0.0的,導(dǎo)致雖然沒有報(bào)錯(cuò)程奠,但是有warning
丈牢,所以需要將項(xiàng)目里面所有使用到的改成26+
第六個(gè)問題:
找不到這個(gè)類support.v4.animation.AnimatorCompatHelper;
這個(gè)應(yīng)該不是升級(jí)導(dǎo)致的,可能是因?yàn)轫?xiàng)目中依賴導(dǎo)致的梦染,姑且暫時(shí)記錄在這里赡麦,因?yàn)槲沂巧?jí)之后出現(xiàn)了這個(gè)問題,具體解決辦法就是
在build.gradle最后添加帕识,代碼如下:
configurations.all?{
???? resolutionStrategy.eachDependency?{
????? DependencyResolveDetails?details?->
???? def?requested?=?details.requested
????????????? if?(requested.group?==?'com.android.support')?{
??????????????????? if?(!requested.name.startsWith("multidex"))?{
??????????????????????????? details.useVersion?'24.1.1'
?????????????????????????????? }
?????????????????? }
?????????? }
}
PS:上述問題解決方案泛粹,基本上都是看了別人博客才知道的,謝謝無私者的奉獻(xiàn)肮疗。