Android Duplicate files copied in APK

今天调试 Android 应用遇到这么个问题:

Duplicate files copied in APK META-INF/DEPENDENCIES File 1: httpmime-4.3.2.jar File 2: httpmime-4.3.2.jar

貌似说两个包里面的文件重复了还是怎么的,谷歌了一番之后据说应该是 android studio 自身的bug

解决办法:

打开项目下面的 build.gradle 文件,在 android 代码块中添加下面代码

  1. android {
  2. packagingOptions {
  3. exclude ‘META-INF/DEPENDENCIES‘
  4. exclude ‘META-INF/NOTICE‘
  5. exclude ‘META-INF/LICENSE‘
  6. exclude ‘META-INF/LICENSE.txt‘
  7. exclude ‘META-INF/NOTICE.txt‘
  8. }
  9. }

将这些文件全部排出掉就ok了

但不知道这么做会不会有什么隐患,还是有其他更好的解决办法

可以参考下这篇文章:http://stackoverflow.com/questions/20853094/gradle-and-android-studio-duplicate-file-copied-from-same-jar

时间: 2024-10-12 22:53:56

Android Duplicate files copied in APK的相关文章

Android Studio - Gradle 更新升级到2.1.0后,发生Duplicate files copied in APK META-INF

今天升级了Android Studio到2.1正式版,发现其建议更新Gradle版本,于是把Gradle更新到2.1.0,但是更新后项目无法跑,报错:Duplicate files copied in APK META-INF. 之前项目也有遇到同样的问题,只需要在app项目中(我的项目有几个子module)添加以下代码就可以了: packagingOptions { exclude 'META-INF/LICENSE.txt' exclude 'META-INF/LICENSE' exclud

Android学习笔记--遇到Duplicate files copied in APK META-INF/LICENSE.txt

在修改老的项目中遇到的此问题,导入jar包的时候报 Error:Execution failed for task ':ADApplication:transformResourcesWithMergeJavaResForDebug'.> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied i

Android Studio 错误 Duplicate files copied in APK META-INF/LICENSE.txt

1 .Duplicate files copied in APK META-INF/LICENSE.txt android { packagingOptions { exclude 'META-INF/LICENSE.txt' } } My logcat: log Execution failed for task ':Prog:packageDebug'. Duplicate files copied in APK META-INF/LICENSE.txt File 1: /home/scij

Duplicate files copied in APK META-INF/LICENSE.txt

Error:Execution failed for task ':app:packageDebug'. > Duplicate files copied in APK META-INF/LICENSE.txt File 1: /Users/weichunsheng/.gradle/caches/modules-2/files-2.1/commons-cli/commons-cli/1.2/2bf96b7aa8b611c177d329452af1dc933e14501c/commons-cli-

Duplicate files copied in APK META-INF/LICENSE 编译失败解决方法

# 错误日志> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/LICENSE File1: /Users/xulun/Downloads/android 2/app/libs/httpclient-4.5.3.jar File2: /Users/xulun

android studio(AS) Duplicate files copied in APK META-INF/NOTICE.txt

File 1: /home/slava/.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpmime/4.3.1/f7899276dddd01d8a42ecfe27e7031fcf9824422/httpmime-4.3.1.jar File 2: /home/slava/.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpmime/4.3.

as项目导入异常"duplicate files copied in apk meta-inf/maven/*"

在导入philm项目的时候出现了上面的错误.最后在stackoverflow上找到了解决方法 解决方法:在build.gradle的Android界面下添加 packagingOptions { exclude 'META-INF/maven/com.squareup.okhttp/okhttp/pom.xml' exclude 'META-INF/maven/com.squareup.okhttp/okhttp/pom.properties' exclude 'META-INF/maven/c

AndrdoidStudio 2个jar包引起的异常Duplicate files copied in APK META-INF/LICENSE.txt

在build.gradle中与compileSdkVersion **.buildToolsVersion “**.**.*"或defaultConfig 同级添加如下代码 packagingOptions{ exclude 'META-INF/LICENSE.txt' exclude 'META-INF/NOTICE.txt'}

错误:com.android.builder.packaging.DuplicateFileException: Duplicate files copied

File2: C:\Users\guoxw\.gradle\caches\modules-2\files-2.1\org.jsoup\jsoup\1.10.3\b842f960942503cf1abbcc8c173a7f2c19d43726\jsoup-1.10.3.jarError:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'. > com.android.build.api.transf