Mpandroidchart: More than one file was found with OS independent path 'META-INF/proguard/androidx-annotations.pro'

Created on 11 Nov 2018  路  6Comments  路  Source: PhilJay/MPAndroidChart

Hi I have a problem with com.github.PhilJay:MPAndroidChart library I want to add to my project when I sync my project everything is ok but when I compile my project it appears this error and I don't know why.

The problem says: More than one file was found with OS independent path 'META-INF/proguard/androidx-annotations.pro'

It supposed that I put everything in the right place

build.gradle (Module app)

` apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "company.eduardo.administradorfinanzas"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        javaCompileOptions {
            annotationProcessorOptions {
                arguments = ["room.schemaLocation": "$projectDir/schemas".toString()]
            }
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

repositories {
    jcenter()
    maven { url 'https://jitpack.io' }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0-alpha'
    //noinspection GradleCompatible
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:cardview-v7:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'


    implementation 'com.google.android.gms:play-services-auth:16.0.1'
    implementation 'com.github.bumptech.glide:glide:4.8.0'
    implementation 'android.arch.persistence.room:runtime:1.1.1'
    annotationProcessor 'android.arch.persistence.room:compiler:1.1.1'

    // Room components
    implementation "android.arch.persistence.room:runtime:$rootProject.roomVersion"
    annotationProcessor "android.arch.persistence.room:compiler:$rootProject.roomVersion"
    androidTestImplementation "android.arch.persistence.room:testing:$rootProject.roomVersion"

// Lifecycle components
    implementation "android.arch.lifecycle:extensions:$rootProject.archLifecycleVersion"
    annotationProcessor "android.arch.lifecycle:compiler:$rootProject.archLifecycleVersion"
}
apply plugin: 'com.google.gms.google-services'`

And my build.gradle (Project)

    // Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath 'com.google.gms:google-services:4.0.1'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

ext {
    roomVersion = '1.1.1'
    archLifecycleVersion = '1.1.1'
}

Most helpful comment

So this seems to be a new problem with androidx, although I've yet to find any exact reason. I ran into a similar problem recently as well, and I have no idea what caused it or how exactly I fixed it. All you should have to do to fix this is to add this to the android { } section in your app's 'build.gradle'

packagingOptions {
    exclude 'META-INF/proguard/androidx-annotations.pro'
}

If that doesn't work, then I can't really help. The best thing you can do is to search around stackoverflow.com until you find something that helps, because it seems like there are many ways this can happen.

All 6 comments

So this seems to be a new problem with androidx, although I've yet to find any exact reason. I ran into a similar problem recently as well, and I have no idea what caused it or how exactly I fixed it. All you should have to do to fix this is to add this to the android { } section in your app's 'build.gradle'

packagingOptions {
    exclude 'META-INF/proguard/androidx-annotations.pro'
}

If that doesn't work, then I can't really help. The best thing you can do is to search around stackoverflow.com until you find something that helps, because it seems like there are many ways this can happen.

I would actually suggest removing these lines from your dependencies to see if anything changes with the error or if it goes away completely:

testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

I think that was how I fixed the problem in a recent project I made, where all I did was create a new project, included this library, and I instantly had a problem with the 'LICENSE' file. I think I removed those lines and my app started building correctly after that.

Another suggestion, and I don't know if it'll work, but you could try closing Android Studio, restarting your computer, and it might work. Like I said this seems to be caused by androidx and can be caused by many different things.

Thanks I solved the problem wih the

packagingOptions { exclude 'META-INF/proguard/androidx-annotations.pro' }

Now everything works fine!

Good to hear!

@Tech-AJ good to hear! But please, don't post your own solution unless it's fairly different from the one already posted. You have copied Lexar7's answer exactly, so there is no reason to post it twice.

thank you @Lexar7 it solved my problem !!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Nima9Faraji picture Nima9Faraji  路  3Comments

AndroidJiang picture AndroidJiang  路  3Comments

rohitkumarbhagat picture rohitkumarbhagat  路  3Comments

SutharRohit picture SutharRohit  路  3Comments

vishvendu picture vishvendu  路  3Comments