升级gradle到3.0.1的时候,app.gradle报了如下几种错误错误:主要是将以前的output.outputFile替换为outputFileName。

Could not get unknown property 'outputFile' for BuildType_Decorated{name=output, debuggable=false, testCoverageEnabled=false, jniDebuggable=false, pseudoLocalesEnabled=false, renderscriptDebuggable=false, renderscriptOptimLevel=3, minifyEnabled=false, zipAlignEnabled=true, signingConfig=null, embedMicroApp=true, 
Ambiguous method overloading for method java.io.File# . Cannot resolve which method to invoke for [class java.lang.String, null] due to overlapping prototypes between: [class java.lang.String, class java.lang.String] [class java.lang.String, class java.io.File] Open File
No signature of method: java.util.ArrayList.endsWith() is applicable for argument types: (java.lang.String) values: [.apk] Open File

反正不管是哪种错误,最后经过翻阅各个博客资料,和自己的尝试,修改为下面的方案总算是可以了。

  //自定义打包时apk名字        android.applicationVariants.all { variant ->            variant.outputs.all { output ->                def fileName                if (outputFileName != null && outputFileName.contains('.apk')) {                    if (variant.buildType.name.equals('release')) {                        //输出示例:  yilv-huawei-release.apk                        fileName = "yilv-${variant.productFlavors[0].name}-${defaultConfig.versionName}-relese.apk"                    } else if (variant.buildType.name.equals('debug')) {                        fileName = "yilv-${variant.productFlavors[0].name}-${defaultConfig.versionName}-debug.apk"                    }                    outputFileName = fileName                }            }        }//渠道        productFlavors {            develop {}            xiaomi {}            huawei {}        }

当然了,这是在区分debug包和release包的输出,如果不要区分的话,就直接输出就好了:

//自定义打包时apk名字        android.applicationVariants.all { variant ->              variant.outputs.all {                
                 outputFileName = "app-${defaultConfig.versionName}-debug.apk"
} }
至于添加版本号和versionName之类的方法,网上已经很多了,大家随便一搜就搜到了。我就不BB了  

更多相关文章

  1. Android(安卓)Ant打包打入第三方包报错解决方案
  2. 编译android sdk时的出错out/host/linux-x86/obj/STATIC_...
  3. Flutter-APP打包流程
  4. JNI中的本地方法添加调试信息
  5. Others1
  6. [Android] Eclipse错误:Conversion to Dalvik format failed with
  7. android 命令行打包
  8. cocos2dx的学习
  9. android 打包混淆报错问题

随机推荐

  1. Android应用程序线程消息循环模型分析
  2. Android框架的深度分析1
  3. Android(安卓)Sqlite数据库查询或删除N天
  4. Android 之 uses-permission
  5. android webkit JavaScript 不能处理onke
  6. Android应用程序资源——Animation动画资
  7. Android.mk——makefile分析
  8. Android中invalidate()和postInvalidate(
  9. QQ音乐Android客户端Web页面通用性能优化
  10. 【Android】自定义FlowLayout,支持多种布