我正在尝试构建,但是它给了我错误。我做了研究,并尝试了以下解决方案,但无法解决。
https://github.com/objectbox/objectbox-java/issues/386
Unable to merge dex
Error - Android resource linking failed (AAPT2 27.0.3 Daemon #0)
Error: Program type already present: androidx.versionedparcelable.ParcelImpl
那就是错误
Error: Program type already present: androidx.versionedparcelable.NonParcelField
多数民众赞成在屏幕上
那就是我的代码
// 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.3.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.30"
// 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
}
和这个
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.adultgaming.fantasygameapp"
minSdkVersion 17
targetSdkVersion 27
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:multidex:1.0.3'
//Kotlin
implementation "androidx.core:core-ktx:1.0.1"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.30"
//Glide
implementation 'com.github.bumptech.glide:glide:4.9.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
//Eventbus
implementation 'org.greenrobot:eventbus:3.1.1'
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'
}
如果我错过了什么,请告诉我。如果要投入,让我知道为什么。
最佳答案
首先,检查您的gradle.properties内部是否有
android.enableJetifier=true
android.useAndroidX=true
然后,您确实启用了androidx。
此外,这可能很明显,但是请使用Build-> Clean Project来清洁Gradle构建
用答案更新
发生的情况是您的其他库之一正在使用androidx,GLIDE FOR SURE以及其他库。
您有两个选择...
简易:升级到androidx ...为什么不呢?完全值得的。
难:将您的依赖项版本降级为androidX之前的版本。
关于android - 未能通过androidX错误进行构建,但我未在项目中使用androidX,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57226315/