Android Gradle 更新到 3.4.1 问题记录

  • 1、多渠道打包会出现问题
    • 属性不能用的问题
    • 打包维度不统一的问题
  • 2、之后就是提示你修改 complie 、testCompile、apt、等等
  • 最后还有几个自身项目中导致的问题
    • 1 、Cannot create variant 'android-aidl' after configuration':xxxxxxxx:debugApiElements' has been resolved
    • 2 、Failed to transform file 'xxxxx.jar' to match attributes {artifactType=android-classes, org.gradle.usage=java-runtime-jars}

ps:有些问题是都会出现的,一些是项目自身导致的可忽略

1、多渠道打包会出现问题

属性不能用的问题

groovy.lang.GroovyRuntimeException: Cannot set the value of read-only property ‘outputFile’ for ApkVariantOutputImpl_Decorated{apkData=Main{type=MAIN, fullName=xiaomiDebug, filters=[], versionCode=3256, versionName=6.2.0}} of type com.android.build.gradle.internal.api.ApkVariantOutputImpl.

outputFile这个属性不能用了

3.0以前一般都这样写

applicationVariants.all { variant ->                variant.outputs.each { output ->                    def outputFile = output.outputFile                    if (outputFile != null && outputFile.name.endsWith('.apk')) {                        // 输出apk名称为news_v1.0_2017-01-15_wandoujia.apk                        def fileName = "news_v${defaultConfig.versionName}_${releaseTime()}_${variant.productFlavors[0].name}.apk"                        output.outputFile = new File(outputFile.parent, fileName)                    }                }            }

属性不能用了就要修改一下,这里要改两个地方

 applicationVariants.all { variant ->                variant.outputs.all { output ->                    def outputFile = output.outputFile                    if (outputFile != null && outputFile.name.endsWith('.apk')) {                        // 输出apk名称为news_v1.0_2017-01-15_wandoujia.apk                        def fileName = "news_v${defaultConfig.versionName}_${releaseTime()}_${variant.productFlavors[0].name}.apk"                        outputFileName = fileName                    }                }            }

完事你可能还会出现

打包维度不统一的问题

All flavors must now belong to a named flavor dimension

这个只需要在 defaultConfig {}里面添加上统一的维度就行了

efaultConfig {flavorDimensions "xxx"}

2、之后就是提示你修改 complie 、testCompile、apt、等等

WARNING: Configuration ‘compile’ is obsolete and has been replaced with ‘implementation’ and ‘api’.

最后还有几个自身项目中导致的问题

1 、Cannot create variant ‘android-aidl’ after configuration’:xxxxxxxx:debugApiElements’ has been resolved

这个是因为一个module 里面有

classpath = files(variant.javaCompile.classpath.files, project.android.getBootClasspath())

用dofist{}包起来就好了

doFirst {            classpath = files(variant.javaCompile.classpath.files, project.android.getBootClasspath())        }

2 、Failed to transform file ‘xxxxx.jar’ to match attributes {artifactType=android-classes, org.gradle.usage=java-runtime-jars}

你所依赖的jar包或者其他第三方库不存在或者不正确。这个错误其很简单,就是你引用的jar包路径错了、版本错了或者不存在,检查一下改改就行了

更多相关文章

  1. ionic 打包报某些jar包重复
  2. fastlane实现Android自动化打包
  3. android layout的一些注意事项
  4. Android开发:界面布局的基本使用
  5. Android(安卓)常用的intent Action整理
  6. 关于Android自定义属性你可能不知道的细节
  7. Android(安卓)动态设置TextView的drawableLeft等属性
  8. Android资源管理中的Theme和Style-------之总述(一)
  9. android 中几个常用属性的设置

随机推荐

  1. android APT 切换 annotationProcessor使
  2. Android(安卓)Http访问网络 学习(慕课网学
  3. Qt for android 开机自启动、开机黑屏处
  4. android显示单位
  5. Android工程中javax annotation Nullable
  6. Android(安卓)adapter has changed解决方
  7. 关于Ant编译Android中Ant学习研究
  8. android 内存占用 分析工具
  9. Android(安卓)短信模块分析(八) MMS数据
  10. android opengl es 纹理贴图资料