weeznn
weeznn
2016-07-11 09:42

android studio打包apk时报错

android studio 在添加了第三方库之后出现问题(编译ok,运行报错):


 Error:duplicate files during packaging of APK E:\android\hikeplus\app\build\outputs\apk\app-debug-unaligned.apk
    Path in archive: assets/MojingSDK/InputMap_mojing_default.json
    Origin 1: E:\android\hikeplus\app\build\intermediates\res\resources-debug.ap_
    Origin 2: E:\android\hikeplus\app\build\intermediates\transforms\mergeJavaRes\debug\jars\2\1f\main.jar
You can ignore those files in your build.gradle:
    android {
      packagingOptions {
        exclude 'assets/MojingSDK/InputMap_mojing_default.json'
      }
    }
Error:Execution failed for task ':app:packageDebug'.
> Duplicate files copied in APK assets/MojingSDK/InputMap_mojing_default.json
    File1: E:\android\hikeplus\app\build\intermediates\res\resources-debug.ap_
    File2: E:\android\hikeplus\app\build\intermediates\transforms\mergeJavaRes\debug\jars\2\1f\main.jar

按照提示,在build.gradle中添加以下语句后的文件为:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "com.nuc.hikeplus"
        minSdkVersion 19
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    packagingOptions {
        exclude 'assets/MojingSDK/MobileConfig.json'
        exclude 'assets/MojingSDK/Glassesfig.json'
        exclude 'assets/MojingSDK/InputMap_default.json'
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.2.1'
    compile 'com.android.support:design:23.2.1'
    compile files('libs/unity-classes.jar')
    compile files('libs/MojingSDK.jar')
    compile files('libs/MojingSDKUnity.jar')
}


编译成功但运行依旧提示该错误

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

2条回答

为你推荐

换一换