1. Error while generating the main dex list
通常是引用了重复的包导致,第三方的包会引入不同版本的类库。通过gradle dependencies检查是否有重复引入的包。排除重复引入.
2. appcompat-v7 27.0.3升级28.0.0是会导致报错,无法编译
需要注意的是28需要更高的android plugin版本,因此需要升级gradle plugin
3. gradle plugin升级至高版本(3.2.1),gradle编译打包报错
执行
gradle app:transformNativeLibsWithMergeJniLibsForDebug
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformNativeLibsWithMergeJniLibsForDebug'.
> org/apache/commons/codec/binary/Base64
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
打开stacktrace看到如下结果
Caused by: java.lang.NoClassDefFoundError: org/apache/commons/codec/binary/Base64
at com.android.builder.files.FileCacheByPath.key(FileCacheByPath.java:125)
at com.android.builder.files.FileCacheByPath.add(FileCacheByPath.java:81)
at com.android.build.gradle.internal.pipeline.IncrementalFileMergerTransformUtils.lambda$toNonIncrementalInput$6(IncrementalFileMergerTransformUtils.java:142)
at com.android.tools.build.apkzlib.utils.IOExceptionRunnable.lambda$asRunnable$0(IOExceptionRunnable.java:41)
at com.android.build.gradle.internal.transforms.MergeJavaResourcesTransform.transform(MergeJavaResourcesTransform.java:414)
at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:239)
at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:235)
at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:102)
at com.android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.java:230)
因此在buildscript新增需要的commons-codec包
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath "commons-codec:commons-codec:1.11"
classpath "com.jakewharton:butterknife-gradle-plugin:9.0.0-rc1"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
有关何种原因加入Base64操作,待后续补充