build.gradle
classpath 'com.android.tools.build:gradle:3.0.0'
gradle
gradle-4.1-all.zip
1.文件的输出路径
- Error:(130, 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`
variant.outputs.all {output ->
outputFileName = filename
}
Error:Cannot choose between the following configurations of project :videoplayer:
- debugApiElements
- debugRuntimeElements
- releaseApiElements
- releaseRuntimeElements
All of them match the consumer attributes:
- Configuration 'debugApiElements':
- Found com.android.build.api.attributes.BuildTypeAttr 'debug' but wasn't required.
- Found com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but wasn't required.
- Found com.android.build.gradle.internal.dependency.VariantAttr 'debug' but wasn't required.
- Found org.gradle.api.attributes.Usage 'java-api' but wasn't required.
- Configuration 'debugRuntimeElements':
- Found com.android.build.api.attributes.BuildTypeAttr 'debug' but wasn't required.
- Found com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but wasn't required.
- Found com.android.build.gradle.internal.dependency.VariantAttr 'debug' but wasn't required.
- Found org.gradle.api.attributes.Usage 'java-runtime' but wasn't required.
- Configuration 'releaseApiElements':
- Found com.android.build.api.attributes.BuildTypeAttr 'release' but wasn't required.
- Found com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but wasn't required.
- Found com.android.build.gradle.internal.dependency.VariantAttr 'release' but wasn't required.
- Found org.gradle.api.attributes.Usage 'java-api' but wasn't required.
- Configuration 'releaseRuntimeElements':
- Found com.android.build.api.attributes.BuildTypeAttr 'release' but wasn't required.
- Found com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but wasn't required.
- Found com.android.build.gradle.internal.dependency.VariantAttr 'release' but wasn't required.
- Found org.gradle.api.attributes.Usage 'java-runtime' but wasn't required.
以前Android Studio不会自动匹配Library中的BuildTypes,3.0以后可以自动匹配了(只要app选择了debug,后面会自动选中debug,release也是一样)
Library中需要添加buildTypes跟app的一样,比如App中有 release debug debugTest,那么Library中也要有这3个 。
3。
如果你用了类似butterknife,需要做如下改动
project的build.gradle文件中删除
classpath ‘com.neenbedankt.gradle.plugins:android-apt:1.8’
module的build.gradle文件中删除
apply plugin: ‘android-apt’
//apt 'com.jakewharton:butterknife-compiler:8.4.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
因为apt是个人开发者开发的,后来google官方出了对应的是annotationProcessor以后直接使用这个
gradle也提示升级到3.0.0版本,编译之前正常的项目后报错Error:com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
这里写图片描述,查看官方文档后了解到
这里写图片描述在gradle 3.0.0中AAPT2是默认打开的,在项目的gradle.properties中添加android.enableAapt2=false,sync后就编译通过了。
备注:部分内容参考其他博客主的。未列出。
网友评论