On gradle:3.0.0 More than one file was found with OS independent path 'META-INF/ASL2.0'

一世执手 提交于 2019-12-28 13:22:11

问题


I have updated my Android studio to 3.0 and then he asked to upgrade to 'com.android.tools.build:gradle:3.0.0'

everything went well until i decided to run my project and it's giving me this Error

Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.

More than one file was found with OS independent path 'META-INF/ASL2.0'

My app gradle

   android {
    compileSdkVersion 26
    buildToolsVersion "26.0.2"
    useLibrary 'org.apache.http.legacy'
    defaultConfig {
        applicationId "com.test.demo"
        minSdkVersion 16
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}'

My Library gradle

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.2"
    useLibrary 'org.apache.http.legacy'

    defaultConfig {
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_6
            targetCompatibility JavaVersion.VERSION_1_6
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/ASL2.0'
    }
}

回答1:


You should add to application build.gradle your packagingOptions:

packagingOptions {
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/license.txt'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/notice.txt'
    exclude 'META-INF/ASL2.0'
}



回答2:


Try this first before you try other methods.

first:

check if you have set this in you build.gradle->dependencies

implementation fileTree(include: ['*.jar'], dir: 'libs')

if you've set this in you build.gradle file then check for this too if you tried to import libraries from your libs directory:

implementation files('libs/...')

if you have this too in your build.gradle file, please remove it or comment it out, because you are trying to re-import the library again which result is that error.



来源:https://stackoverflow.com/questions/46956341/on-gradle3-0-0-more-than-one-file-was-found-with-os-independent-path-meta-inf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!