android - 未能通过androidX错误进行构建,但我未在项目中使用androidX

标签 android gradle kotlin

我正在尝试构建,但是它给了我错误。我做了研究,并尝试了以下解决方案,但无法解决。
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

多数民众赞成在屏幕上
enter image description here

那就是我的代码
// 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之前的版本。

Glide Repo

关于android - 未能通过androidX错误进行构建,但我未在项目中使用androidX,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57226315/

相关文章:

android - Google 从 Android 登录并访问服务器的身份验证 token

android - 如何在 Android Studio 中授予对 registry.bin 的访问权限?

android-studio - 错误 : This project uses AndroidX dependencies, 但 'android.useAndroidX' 属性未启用。在 gradle.prop 中将此属性设置为 true

java - 如何在android中创建一个新文件夹?

proguard - 如何防止 kotlin.Unit 对象被 Proguard 剥离

php - 帮忙解析resources.arsc?

android - android图像位置错误

android - 如何满足 'filter in' 条件的 'where not equal to' firestore 数据?

java - Android 抛出 DeadObjectException : Transaction failed on small parcel; remote process probably died just in HUAWEI Android 8. 0.0

java - 如何将开关传递给我的 Android 应用程序以控制其在开发过程中的行为?