升级到 Android Studio 3.0 + Gradle 4.1 遇到的一些坑及解决方案
来源:互联网 发布:小米换苹果 迁移数据 编辑:程序博客网 时间:2024/06/06 12:39
问题一:
Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated{apkData=Main{type=MAIN, fullName=commonDebug, filters=[]}} of type com.android.build.gradle.internal.api.ApkVariantOutputImpl. Open File
解决方案一:
https://stackoverflow.com/questions/44239235/android-gradle-3-0-0-alpha2-plugin-cannot-set-the-value-of-read-only-property
I used this code
applicationVariants.all { variant -> variant.outputs.each { output -> def outputFile = output.outputFile if (outputFile != null && outputFile.name.endsWith('.apk')) { //输出apk名称为:应用名.apk def fileName = "xxx.apk" output.outputFile = new File(outputFile.parent, fileName) } } }
**Use all() instead of each()
Use outputFileName instead of output.outputFile if you change only file name (that is your case)**
Example from the guide:
// If you use each() to iterate through the variant objects,// you need to start using all(). That's because each() iterates// through only the objects that already exist during configuration time—// but those object don't exist at configuration time with the new model.// However, all() adapts to the new model by picking up object as they are// added during execution.android.applicationVariants.all { variant -> variant.outputs.all { outputFileName = "xxx.apk" } }
问题二:
Error:All flavors must now belong to a named flavor dimension. Learn more at https://d.android.com/r/tools/flavorDimensions-missing-error-message.html
解决方案二:
http://blog.csdn.net/syif88/article/details/75009663
大致是说,Plugin 3.0.0之后有一种自动匹配消耗库的机制,便于debug variant 自动消耗一个库,然后就是必须要所有的flavor 都属于同一个维度。
为了避免flavor 不同产生误差的问题,应该在所有的库模块都使用同一个foo尺寸。
但是我们从中已经知道解决方案了:
在主 app 的 build.gradle 里面的
defaultConfig { targetSdkVersion:*** minSdkVersion :*** versionCode:*** versionName :***//版本名后面加句话,意思是flavor dimension 它的维度就是该版本号,//这样维度就是都是统一的了 **flavorDimensions "versionCode"**}
问题三:
Error:Execution failed for task ':youyoubao:javaPreCompileCommonDebug'.> Annotation processors must be explicitly declared now. The following dependencies on the compile classpath are found to contain annotation processor. Please add them to the annotationProcessor configuration. - butterknife-compiler-8.6.0.jar (com.jakewharton:butterknife-compiler:8.6.0) Alternatively, set android.defaultConfig.javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true to continue with previous behavior. Note that this option is deprecated and will be removed in the future. See https://developer.android.com/r/tools/annotation-processor-error-message.html for more details.
解决方案三:
在 app 下的 build.gradle 的 defaultConfig 中加一句话:
defaultConfig { ... javaCompileOptions { annotationProcessorOptions { includeCompileClasspath = true } }}
阅读全文
0 0
- 升级到 Android Studio 3.0 + Gradle 4.1 遇到的一些坑及解决方案
- 升级Android Studio到3.0遇到的一些问题
- Android Studio 升级到3.0,gradle升级到4.1后报错
- Android Studio 升级到3.0遇到的坑
- Android Studio升级2.3 gradle升级慢的问题 解决方案
- android studio、gradle升级后遇到的问题
- 升级到Android Studio 3.0遇到的几个错误
- Android studio 升级到3.0时项目遇到的问题
- Android Studio 自动升级 gradle 失败解决方案
- android studio升级到3.0之后的一些配置变化
- android studio gradle和安装遇到的一些问题
- Android Studio 导入项目时Gradle遇到的一些问题
- 升级Gradle 3.0遇到的坑
- Android Studio 3.0及Gradle Plugin 3.0升级注意事项
- Android Studio使用过程中遇到的一些问题及解决方案
- Android Studio使用过程中遇到的一些问题及解决方案
- Android Studio使用过程中遇到的一些问题及解决方案
- 升级Android Studio 3.0 遇到的问题
- crypto++RSA数字签名
- 数据流_小记
- AES加密方式整理
- Markdown编辑之图片去水印
- DB2中的空值和NULL处理
- 升级到 Android Studio 3.0 + Gradle 4.1 遇到的一些坑及解决方案
- dubbo源码解析
- Dex文件格式
- stm32f103串口实现重映射功能
- Chip Factory(字典树,学会将路暂时删除)
- 百度UEditor
- Python匿名函数详解
- Javascript模块化编程(二):AMD规范
- 刷题记录