Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲
 Android教程網 >> Android技術 >> 關於Android編程 >> Android問題集錦之四十八:Error:duplicate files during packaging of APK

Android問題集錦之四十八:Error:duplicate files during packaging of APK

編輯:關於Android編程

在將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'
    }
    。。。

 

  1. 上一頁:
  2. 下一頁:
熱門文章
閱讀排行版
Copyright © Android教程網 All Rights Reserved