【发布时间】: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”在做什么,或者该条目位于何处。我的问题是重复文件,还是另一个文件中的重复引用?
我不知道还能尝试什么。有人可以帮忙吗?
【问题讨论】: