【问题标题】:Android app run fails with "duplicate entry: META-INF/services" errorAndroid 应用程序运行失败,出现“重复条目:META-INF/services”错误
【发布时间】:2020-10-11 15:25:49
【问题描述】:

我正在尝试将我的应用程序转换为 AndroidX。我已将其更新到版本 28(饼图),然后使用“重构迁移到 Android X”将其转换为 Android X。一切似乎都正常,项目在几秒钟内同步正常。

当我尝试构建文件(使用 build:rebuild 项目)或在模拟器上运行它时出现问题 - 运行失败并显示消息

Cause:duplicate entry: META-INF/services/javax.annotation.processing.Processor

我在 build.gradle 文件中尝试了几个不同的“打包选项”条目,包括:

packagingOptions {
        exclude 'META-INF/*'
    }

packagingOptions {
        pickFirst 'META-INF/*'
    }

packagingOptions {
        exclude 'META-INF/services/javax.annotation.processing.Processor'
    }

但我每次都收到相同的消息。但是,如果我清理项目(构建:清理项目),那么它会说构建正常。

我的 build.gradle 文件目前如下所示:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 30
    buildToolsVersion "27.0.3"

    defaultConfig {
        applicationId "com.barney.aboutmyjourney"
        minSdkVersion 16
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

    packagingOptions {
        exclude 'META-INF/*'
    }
}

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation 'androidx.appcompat:appcompat:1.0.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.google.android.gms:play-services-location:17.1.0'
    implementation 'com.github.bumptech.glide:glide:4.2.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.2.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'

}

我是一名 Android 爱好者,我不得不承认我并不真正了解“META-INF/services”在做什么,或者该条目位于何处。我的问题是重复文件,还是另一个文件中的重复引用?

我不知道还能尝试什么。有人可以帮忙吗?

【问题讨论】:

    标签: android meta-inf


    【解决方案1】:

    我做了一些更改,包括将一些 build.gradle 依赖项更新到更高版本,问题已经消失了。

    我仍然不明白导致问题的原因或解决了该问题的具体措施,所以如果有人能给出任何解释,如果再次发生,我将不胜感激。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-12-04
      • 2019-12-20
      • 1970-01-01
      • 2014-01-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-16
      相关资源
      最近更新 更多