com.github.PhilJay:MPAndroidChart库的问题

时间:2018-11-11 17:08:44

标签: android gradle android-gradle androidx

嗨,我有com.github.PhilJay:MPAndroidChart库问题,我想在同步项目时将其添加到我的项目中,一切都很好,但是当我编译我的项目时,出现此错误,我不知道为什么。

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

假设我把所有东西放在正确的位置

build.gradle(模块应用程序)

    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'

还有我的build.gradle(项目)

    // 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'
}

1 个答案:

答案 0 :(得分:0)

可以使用stable version

dependencies {
    // implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.github.PhilJay:MPAndroidChart:v3.0.2"
}

或将重复的androidx-annotations.pro限制为一个条目:

android {
    packagingOptions {
        pickFirst "META-INF/proguard/androidx-annotations.pro"
    }
}

还检查libs目录,如果不是重复条目源自*.jar,因为文件androidx-annotations.pro听起来像是ProGuard使用者规则文件,因为通常由图书馆提供。并且google-services插件当前的版本为4.1.0