安卓工作室 : Error: Program type already present: androidx. core.graphics.PathSegment

标签 android android-studio gradle

我使用的是 Android Studio 3.3 Canary 8。 我创建了默认项目,然后尝试运行该项目。 但我看到了以下堆栈跟踪:

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

构建.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'
}

最佳答案

替换

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

implementation "androidx.core:core-ktx:1.0.0"// Updated version

关于安卓工作室 : Error: Program type already present: androidx. core.graphics.PathSegment,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52137361/

相关文章:

java - 如何在android studio中创建新的activity

java - 在 Android Studio 中使用 Netbeans 的 JDK

android - Android AVD只能一次启动

java - gradle 依赖项的 "compile group"是什么?不同的组件有什么作用?

intellij-idea - Gradle 设置错误

android - 资源 $NotFoundException : Resource is not a ColorStateList (color or path): } in android

javascript - 安卓:用JS设置window.location

android - 将 android 库添加到 Studio/SDK 中的默认库列表

java - 动态获取图像到ImageView

java - 构建任务和 sourceCompatibility = 1.7、gradle 5.3 的问题