1.gradle打包,自定义apk名称代码报错(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.
Open File
解决 :修改文件名代码请这样写
?
1
2
3
4
5
android.applicationVariants.all
{ variant ->
variant.outputs.all
{
outputFileName
= "xinlebao_${defaultConfig.versionName}_${releaseTime()}.apk"
}
}
2. AAPT2 编译报错 AAPT2 error
报错
Error:java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
解决:在gradle.properties中关闭APPT2 编译
?
1
android.enableAapt2=false
注:如果是eclipse转到as上的项目,可能没有gradle.properties文件,请在项目根目录中手动创建
3.apt插件问题(Error:Cannot choose between the following configurations of project :mylibrary:)
报错:
Error:Cannot choose between the following configurations of project :mylibrary:
- debugApiElements
- debugRuntimeElements
- releaseApiElements
- releaseRuntimeElements
All of them match the consumer attributes:
解决
?
1
2
3
4
5
6
7
8
//1.在project的build.gradle中删除
classpath
'com.neenbedankt.gradle.plugins:android-apt:1.8'
//2.在module的build.gradle中删除
apply
plugin: 'android-apt'
//3.将module的build.gradle文件中的dependency
apt
'com.jakewharton:butterknife-compiler:8.1.0'
//改为
annotationProcessor
'com.jakewharton:butterknife-compiler:8.1.0'
其他使用apt的依赖,也要这样更改
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。
原文链接:http://www.jianshu.com/p/9af06314e036