Bo Z
Bo Z

Reputation: 2607

Failing on build with androidX error but I am not using androidX in project

I am trying to build but it gives me errors. I did research and tried following solutions but cant fix. 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

Thats the error

Error: Program type already present: androidx.versionedparcelable.NonParcelField

Thats the screen enter image description here

Thats my code

// 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
}

and this one

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'
}

Please let me know if I missed something. And if want to devote let me know why.

Upvotes: 0

Views: 233

Answers (1)

Richard Dapice
Richard Dapice

Reputation: 885

First, check inside your gradle.properties, if you have

android.enableJetifier=true
android.useAndroidX=true 

Then you do have androidx enabled.

Also, and this may be obvious, but clean your Gradle build with Build -> Clean Project

UPDATE WITH ANSWER What is happening is one of your other libraries is using androidx, GLIDE FOR SURE, and maybe others.

You have two options...

Easy: Upgrade to androidx... Like why not? Totally worth it.

Hard: Downgrade your dependencies versions to pre androidX versions.

Glide Repo

Upvotes: 1

Related Questions