Error: “Program type already present: androidx.versionedparcelable.CustomVersionedParcelable”

末鹿安然 提交于 2019-12-10 01:50:14

问题


I am having trouble with the following Error --> Error: Program type already present: androidx.versionedparcelable.CustomVersionedParcelable

When I click in Build errors it shows me this:

AGPBI: {"kind":"error","text":"Program type already present: androidx.versionedparcelable.CustomVersionedParcelable","sources":[{}],"tool":"D8"}
:app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED
FAILURE: Build failed with an exception.

I don't understand what it is causing this problem because I am using Parcelable library but never caused me this type of error.

This is my project's gradle file.

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.package.name"
        minSdkVersion 22
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    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'
    // Lottie
    implementation 'com.airbnb.android:lottie:2.8.0'
    //Gson
    implementation 'com.google.code.gson:gson:2.8.5'
    implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
    //Dagger 2
    implementation 'com.google.dagger:dagger:2.18'
    implementation "com.google.dagger:dagger-android-support:2.18"
    annotationProcessor 'com.google.dagger:dagger-compiler:2.18'
    //Asyncjob
    implementation 'com.arasthel:asyncjob-library:1.0.3'
    //Butterknife
    implementation 'com.jakewharton:butterknife:9.0.0-rc1'
    annotationProcessor 'com.jakewharton:butterknife-compiler:9.0.0-rc1'
}

This is my Build panel in Android Studio

Any thoughts?? Thanks!!

UPDATE (12-1-2018)

I think I have found the answer for this problem. I read that all the support libraries are going to migrate to androidx library.

So I have read in the Android Developers Documentation and explain how to migrate all the android.support. libraries to androidx.

You only have to go to Android Studio and make Refactor >> Migrate to AndroidX from the menu bar.

This is the link for more information --> Android Developers Documentation (Migrate to Androidx).


回答1:


Add this in your gradle.properties file

android.useAndroidX=true
android.enableJetifier=true



回答2:


Only this solution works for me after a long time of search.

Android Studio Menu -> Build -> Rebuild Project.

Source Here.




回答3:


Problem:

Error: Program type already present:

androidx.versionedparcelable.CustomVersionedParcelable

Solution: Add this in your gradle.properties file in the top.

android.useAndroidX=true

android.enableJetifier=true

Your Project will migrate to androidx with no error during build time



来源:https://stackoverflow.com/questions/53570454/error-program-type-already-present-androidx-versionedparcelable-customversion

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!