Android问题集锦之四十八:Error:duplicate files during packaging of APK

端午小长假最后一天,大雨。只好在家里鼓捣自己喜欢的代码了。

在将dom4j.jar也加入fastjson测试程序中,编译出错,如下:

Error:duplicate files during packaging of APK /home/linc/workspace/lab/FastjsonTestor/app/build/outputs/apk/app-debug-unaligned.apk
    Path in archive: META-INF/LICENSE.txt
    Origin 1: /home/linc/workspace/lab/FastjsonTestor/app/libs/fastjson-1.1.45.android.jar
    Origin 2: /home/linc/workspace/lab/FastjsonTestor/app/libs/dom4j-1.6.1.jar
You can ignore those files in your build.gradle:
    android {
      packagingOptions {
        exclude ‘META-INF/LICENSE.txt‘
      }
    }
Error:Execution failed for task ‘:app:packageDebug‘.
> Duplicate files copied in APK META-INF/LICENSE.txt
    File 1: /home/linc/workspace/lab/FastjsonTestor/app/libs/fastjson-1.1.45.android.jar
    File 2: /home/linc/workspace/lab/FastjsonTestor/app/libs/dom4j-1.6.1.jar

原来LICENSE.txt出现了冲突,根据提示,我们只要在build.gradle中做些修改将LICENSE.txt剔除出去即可。

android {
    compileSdkVersion 19
    buildToolsVersion "19.1.0"

    defaultConfig {
        applicationId "com.linc.fastjsontestor"
        minSdkVersion 19
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
    }

    packagingOptions {
        exclude ‘META-INF/NOTICE‘
        exclude ‘META-INF/LICENSE‘
        exclude ‘META-INF/LICENSE.txt‘
        exclude ‘META-INF/NOTICE.txt‘
    }
    。。。

参考:

http://stackoverflow.com/questions/22467127/error-duplicate-files-during-packaging-of-apk

时间: 2024-10-14 15:11:44

Android问题集锦之四十八:Error:duplicate files during packaging of APK的相关文章

Error:duplicate files during packaging of APK app\

Error:duplicate files during packaging of APK app\build\outputs\apk\app-debug-unali 这个错误的解决方法是:在app的build.gradle文件中增加以下内容:     packagingOptions {         exclude 'META-INF/DEPENDENCIES.txt'         exclude 'META-INF/LICENSE.txt'         exclude 'META

Error:duplicate files during packaging of APK app/build/output/apk

在gradle配置文件加入: android { packagingOptions { exclude 'META-INF/DEPENDENCIES.txt' exclude 'META-INF/LICENSE.txt' exclude 'META-INF/NOTICE.txt' exclude 'META-INF/NOTICE' exclude 'META-INF/LICENSE' exclude 'META-INF/DEPENDENCIES' exclude 'META-INF/notice

duplicate files during packaging of APK

问题描述 在使用Android studio引入第三方jar包,打包时出错 Error:duplicate files during packaging of APK F:\Travel\app\build\outputs\apk\app-debug-unaligned.apk Path in archive: META-INF/NOTICE.txt Origin 1: F:\Travel\app\libs\commons-codec-1.6.jar Origin 2: F:\Travel\ap

Android问题集锦之四十九:Can't add XStream file dependency to Android Studio project

将xstream1.4.8 引入Android Strudio项目中,编译报错如下: UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dx.cf.iface.ParseException: bad class file magic (cafebabe) or version (0034.0000) at com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:472) at

Android问题集锦之三十八:not allowed to send broadcast android.intent.action.MEDIA_MOUNTED

当我们保存图片后就会发个通知告诉系统让sdcard重新挂载,这样其他程序就会立即找到这张图片. Intent intent = new Intent(); intent.setAction(Intent.ACTION_MEDIA_MOUNTED); intent.setData(Uri.fromFile(Environment .getExternalStorageDirectory())); sendBroadcast(intent); 但是到了Android4.4就不灵了,Google将ME

Android问题集锦之四十二:INSTALL_FAILED_OLDER_SDK

错误描述如下: $ adb install ./app/build/outputs/apk/app-debug.apk 2999 KB/s (8256380 bytes in 2.688s) pkg: /data/local/tmp/app-debug.apk Failure [INSTALL_FAILED_OLDER_SDK] 原因就是您设备的Android版本过低,app不支持. 改正的办法就是在程序的Manifest文件(或build.gradle)中将最低版本号调高. Manifest中

Android问题集锦之四十:Android NDK: Could not find application project directory

记得前阵子编译so库直接使用ndk-build搞定,今天使用却报错如下: $ ndk-build Android NDK: Could not find application project directory ! Android NDK: Please define the NDK_PROJECT_PATH variable to point to it. /opt/android-ndk-r10b/build/core/build-local.mk:148: *** Android NDK

Android实战技巧之四十四:Hello,Native!

在Android上运行C程序对于做上层App的童鞋来说有些陌生,因为目前的Android应用开发怎么还是绕不过Java. 但对于底层驱动开发者,这就是家常便饭一样,因为Android是Linux分支,底层是C/C++的世界. 有时为了测试一些功能,我们也会编写直接运行在Android终端下的C程序.前提是有Android交叉编译器以及Android系统的root权限. 交叉编译工具 ndk为我们开发native程序做了很多工作,下面我们将Android交叉编译工具从ndk中分离出来. 我的系统是

48. 蛤蟆的数据结构笔记之四十八的有向无环图的应用关键路径

48. 蛤蟆的数据结构笔记之四十八的有向无环图的应用关键路径 本篇名言:"富贵不淫贫贱乐 ,男儿到此是豪雄.-- 程颢" 这次来看下有向无环图的另一个应用关键路径. 欢迎转载,转载请标明出处:http://blog.csdn.net/notbaron/article/details/47135061 1.  关键路径 与AOV-网相对应的是AOE-网(Activity On Edge)即边表示活动的网.AOE-网是一个带权的有向无环图,其中,顶点表示事件(Event),弧表示活动,权表