AndroidStudio錯誤

編譯運行出錯信息如下:

Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/LICENSE
File1: C:\Users\lwl\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-databind\2.7.7\f595bc5c04adf4db9d49909216128904a315f198\jackson-databind-2.7.7.jar
File2: C:\Users\lwl\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-annotations\2.7.0\19f42c154ffc689f40a77613bc32caeb17d744e3\jackson-annotations-2.7.0.jar
File3: C:\Users\lwl\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-core\2.7.7\1b45281e277d07ef8c02e9726daef1175442759a\jackson-core-2.7.7.jar


可能是因爲不同jar包包含了不同的JackSonXXX.jar,而JackSon.jar裏面又包含了META-INF/LICENSE所以才發生重複導入出錯,只要在build.gradle添加:

apply plugin: 'com.android.application'
apply plugin: 'me.tatarka.retrolambda'


android {
    signingConfigs {
        debug_config {
            keyAlias 'gci'
            keyPassword 'gci0908'
            storeFile file('D:/GCI/GCI-Project/src_renttravel_android/debug.jks')
            storePassword 'gci0908'
        }
    }
    compileSdkVersion 24
    buildToolsVersion "24.0.2"
    只要添加這個即可,位置不要變,我之前添加到下面不起作用
    packagingOptions {
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE'
    }

    defaultConfig {
        applicationId "com.gci.xxt.ruyue"//應用唯一標示
        minSdkVersion 11
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
        signingConfig signingConfigs.debug_config//設置簽名信息
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    lintOptions {
        abortOnError = Boolean.valueOf(System.getProperty('abort-on-error', 'true'))
        textReport true
        textOutput 'stdout'
    }

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章