Android开发bug集合
持续更新中…
okhttp
情景:导入okHttp和okio两个jar包后,进行配置,运行项目时报:
Error:Execution failed for task ':okhttp:transformResourcesWithMergeJavaResForDebug'.com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/maven/com.squareup.okhttp3/okhttp/pom.properties
File1: D:\Workdata\CodeSpace\TestNetwork\okhttp\libs\okhttp-3.4.1.jar
File2: C:\Users\xxx\.gradle\caches\modules-2\files-2.1\com.squareup.okhttp3\okhttp\3.4.1\c7c4f9e35c2fd5900da24f9872e3971801f08ce0\okhttp-3.4.1.jar
Error:Execution failed for task ':okhttp:transformResourcesWithMergeJavaResForDebug'.
com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/maven/com.squareup.okio/okio/pom.properties
File1: D:\Workdata\CodeSpace\TestNetwork\okhttp\libs\okio-1.10.0.jar
File2: C:\Users\xxx\.gradle\caches\modules-2\files-2.1\com.squareup.okio\okio\1.10.0\c4b316c469df09d8b5b173def1dfd79881a38310\okio-1.10.0.jar
解决方式:
在model下的build.gradle文件中android下加上以下几点:
packagingOptions {
exclude 'META-INF/maven/com.squareup.okhttp3/okhttp/pom.xml'
exclude 'META-INF/maven/com.squareup.okhttp3/okhttp/pom.properties'
exclude 'META-INF/maven/com.squareup.okio/okio/pom.xml'
exclude 'META-INF/maven/com.squareup.okio/okio/pom.properties'
}
环信集成
情景:AS导入ChatDemoUI3.0时正常,运行时报错:
Error:Execution failed for task ':transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/annotation/ColorRes.class
解决方法:
在build.gradle中添加:
configurations{
all*.exclude group: ‘com.android.support’,module:’support-v4’
all*.exclude group: ‘com.android.support’,module:’support-annotations’
}