【问题标题】:Issue with com.github.PhilJay:MPAndroidChart librarycom.github.PhilJay:MPAndroidChart 库的问题
【发布时间】:2018-11-11 17:08:44
【问题描述】:

您好,我的 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'
}

【问题讨论】:

    标签: android gradle android-gradle-plugin androidx


    【解决方案1】:

    要么使用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。

    【讨论】:

    • 我应该把 pakingOptions 放在 build.grade 应用还是 build.gradle prokect 的什么位置?
    • @EduardoNoyola 进入模块的build.gradle,进入android 配置。仍然认为您可能添加了重复的依赖项,因为没有其他逻辑解释,对于存在两次(或不止一次)的文件。几乎不需要添加任何 *.jar 文件,因为正在获取和缓存依赖项。
    • 它说:C:\Users\Carolina\AndroidStudioProjects\AdministradorFinanzas\app\build\intermediates\transforms\mergeJavaRes\debug\0.jar:进程无权访问该文件,因为正在用于其他过程
    • @EduardoNoyola 杀死 gradle 守护进程并删除 app\build。可能存在许可问题,例如。它无法从那里删除以前构建的文件。
    猜你喜欢
    • 1970-01-01
    • 2013-11-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-04
    相关资源
    最近更新 更多