Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio: Error: Program type already present: androidx.core.graphics.PathSegment

I use Android Studio 3.3 Canary 8. I created default project and then I tried run the project. But I had seen following stacktrace:

AGPBI: {"kind":"error","text":"Program type already present: androidx.core.graphics.PathSegment","sources":[{}],"tool":"D8"} Task :app:buildInfoGeneratorDebug FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'. com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes. Program type already present: androidx.core.graphics.PathSegment

build.gradle

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "my.app"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.0.0-rc02'
    implementation 'android.arch.navigation:navigation-fragment:1.0.0-alpha05'
    implementation 'android.arch.navigation:navigation-ui:1.0.0-alpha05'
    implementation 'android.arch.navigation:navigation-fragment-ktx:1.0.0-alpha05'
    implementation 'android.arch.navigation:navigation-ui-ktx:1.0.0-alpha05'
    implementation 'androidx.core:core-ktx:0.3'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'
}
like image 454
Danil Avatar asked Sep 02 '18 13:09

Danil


3 Answers

Seems like a bug on recent Android stuff, which occurs even if you create a new project.

I've reported about this recently here .

The workaround, which I've found by choosing to migrate to Android-x, is this:

implementation 'androidx.core:core-ktx:1.0.0-rc02'

instead of this generated line :

implementation 'androidx.core:core-ktx:0.3'
like image 169
android developer Avatar answered Nov 05 '22 11:11

android developer


Replace

implementation 'androidx.core:core-ktx:0.3'

with

implementation "androidx.core:core-ktx:1.0.0"// Updated version
like image 20
Francesc Avatar answered Nov 05 '22 11:11

Francesc


for this error you have to update this dependency to latest

implementation 'androidx.core:core-ktx:0.3'

like image 1
Muhammad Nauman Avatar answered Nov 05 '22 10:11

Muhammad Nauman