从gradle:2.0.0 到 gradle:3.0.0,项目中修改

  1. enforceUniquePackageName = false 已经不支持,暂时注释掉
  2. apk名称修改

android.applicationVariants.all {
variant ->
variant.outputs.each {
output -> output.outputFile = new File(output.outputFile.parent, “app_” + productFlavors[0].name + “_” + buildType.name + “_v” + defaultConfig.versionName + “-${releaseTime()}.apk”);
}
}

applicationVariants.all { variant ->
    variant.outputs.all { output ->
        def newApkName = applicationId + "-" + variant.versionName + "(" + variant.versionCode + ")" + "-${releaseTime()}.apk";
        outputFileName = new File(variant.name, newApkName);
    }
}

3.删除me.tatarka.retrolambda plugin
4. Warning:The android.dexOptions.incremental property is deprecated and it has no effect on the build process.

dexOptions {
incremental true //开启incremental dexing,优化编译效率,这个功能android studio默认是关闭的。
preDexLibraries = false //让它不要对Lib做preDexing
javaMaxHeapSize “4g” //增加java堆内存大小
}
5 Error:All flavors must now belong to a named flavor dimension. Learn more at https://d.android.com/r

在主app的build.gradle里面的
defaultConfig {
targetSdkVersion:*
minSdkVersion :*
versionCode:*
versionName :*
//版本名后面添加一句话,意思就是flavor dimension 它的维度就是该版本号,这样维度就是都是统一的了
flavorDimensions “versionCode”
}
参考文章:参考文章

6.Error:Execution failed for task ‘:app:javaPreCompileSanocareDebug’.

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-7.0.0.jar (com.jakewharton:butterknife:7.0.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中
android {

defaultConfig {

//添加如下配置就OK了
javaCompileOptions { annotationProcessorOptions { includeCompileClasspath = true } }
}

}
参考文章:参考路径

7.
使用butterknife 8.8.1 gradle 3.0

Error:Unable to find method ‘com.android.build.gradle.api.BaseVariant.getOutputs()Ljava/util/List;’.
Possible causes for this unexpected error include:

  • Gradle’s dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
    Re-download dependencies and sync project (requires network)
  • The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
    Stop Gradle build processes (requires restart)
  • Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.
In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.

解决方法

classpath ‘com.jakewharton:butterknife-gradle-plugin:8.4.0’

8.Error:Execution failed for task ‘:app:transformDexArchiveWithExternalLibsDexMergerForDebug’.

com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
我的不是包重复 解决办法clean
参考解决方案

你可能感兴趣的:(android)