错误:程序类型已经存在:android.support.design.widget.CoordinatorLayout$Behavior [英] Error : Program type already present: android.support.design.widget.CoordinatorLayout$Behavior

查看:37
本文介绍了错误:程序类型已经存在:android.support.design.widget.CoordinatorLayout$Behavior的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在构建项目时遇到以下错误.在这个项目中没有使用 CoordinatorLayout.刚刚在 build.gradle 中添加为依赖项:

I am getting the following error while building the project. haven't used CoordinatorLayout in this project. just added as a dependency in build.gradle :

我使用的是 Android Studio 3.2 Canary 4.

I am using Android Studio 3.2 Canary 4.

LogCat

AGPBI: {"kind":"error","text":"程序类型已经存在:android.support.design.widget.CoordinatorLayout$Behavior","sources":[{}],"tool":D8"}:app:transformDexArchiveWithExternalLibsDexMergerForDebug 失败FAILURE:构建失败,出现异常.* 什么地方出了错:任务:app:transformDexArchiveWithExternalLibsDexMergerForDebug"执行失败.

AGPBI: {"kind":"error","text":"Program type already present: android.support.design.widget.CoordinatorLayout$Behavior","sources":[{}],"tool":"D8"} :app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.

com.android.builder.dexing.DexArchiveMergerException:合并 dex 档案时出错:/windows/Other/app/build/intermediates/transforms/dexBuilder/debug/0.jar、/windows/Other/app/build/intermediates/transforms/dexBuilder/debug/1.jar,/windows/Other/app/build/intermediates/transforms/dexBuilder/debug/4.jar,.....................

com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: /windows/Other/app/build/intermediates/transforms/dexBuilder/debug/0.jar, /windows/Other/app/build/intermediates/transforms/dexBuilder/debug/1.jar, /windows/Other/app/build/intermediates/transforms/dexBuilder/debug/4.jar, . . ...................

/windows/Other/app/build/intermediates/transforms/dexBuilder/debug/294.jar

/windows/Other/app/build/intermediates/transforms/dexBuilder/debug/294.jar

程序类型已经存在:android.support.design.widget.CoordinatorLayout$Behavior

Program type already present: android.support.design.widget.CoordinatorLayout$Behavior

build.gradle

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'

android {
    compileSdkVersion 27
    buildToolsVersion "27.0.3"
    defaultConfig {
        applicationId "com.dagkot"
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            buildConfigField "String", "BASE_URL", ""http://api.openweathermap.org/data/2.5/""
            buildConfigField "String", "API_KEY", ""435e9075f348868c2714fe7c6895efa5""
        }
        debug {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        buildConfigField "String", "BASE_URL", ""http://api.openweathermap.org/data/2.5/""
        buildConfigField "String", "API_KEY", ""xxxx""
    }
}
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.1', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"


    // Dagger dependencies
    compileOnly 'org.glassfish:javax.annotation:10.0-b28'
    implementation "com.google.dagger:dagger:$rootProject.daggerVersion"
    implementation "com.google.dagger:dagger-android:$rootProject.daggerVersion"
    implementation "com.google.dagger:dagger-android-support:$rootProject.daggerVersion"
    kapt "com.google.dagger:dagger-android-processor:$rootProject.daggerVersion"
    kapt "com.google.dagger:dagger-compiler:$rootProject.daggerVersion"

    //Butterknife dependencies
    implementation 'com.jakewharton:butterknife:8.8.1'
    kapt 'com.jakewharton:butterknife-compiler:8.8.1'

    // Architecture Components Dependencies
    kapt "android.arch.lifecycle:compiler:$rootProject.lifeCycle"
    implementation "android.arch.lifecycle:extensions:$rootProject.lifeCycle"
    implementation "android.arch.lifecycle:reactivestreams:$rootProject.lifeCycle"
    implementation "com.android.support:cardview-v7:$rootProject.supportLibraryVersion"

    // Retrofit/RxJava Dependencies
    implementation "com.squareup.retrofit2:retrofit:$rootProject.retrofitVersion"
    implementation "com.squareup.retrofit2:adapter-rxjava2:$rootProject.retrofitVersion"
    implementation "com.squareup.retrofit2:converter-gson:$rootProject.retrofitVersion"
    implementation "io.reactivex.rxjava2:rxandroid:$rootProject.rxAndroidVersion"
    implementation 'com.squareup.okhttp3:logging-interceptor:3.6.0'
    implementation 'com.jakewharton.rxbinding2:rxbinding-kotlin:2.1.1'

    // GSON
    implementation "com.google.code.gson:gson:$rootProject.gsonVersion"

    // Rx Location Manager
    implementation 'io.nlopez.smartlocation:library:3.3.3'
    implementation 'io.nlopez.smartlocation:rx:3.3.1'

    //Anko Dependencies
    implementation "org.jetbrains.anko:anko-commons:$rootProject.anko_version"
    implementation "org.jetbrains.anko:anko-design:$rootProject.anko_version"
    implementation 'com.android.support:design:27.0.2'

    implementation("com.github.hotchemi:permissionsdispatcher:3.1.0") {
        // if you don't use android.app.Fragment you can exclude support for them
        exclude module: "support-v13"
    }
    kapt "com.github.hotchemi:permissionsdispatcher-processor:3.1.0"
}

推荐答案

当我降级支持 appcompat gradle 依赖项时它起作用了,如下所示:

It worked when I downgrade the support appcompat gradle dependency, like follwing :

implementation 'com.android.support:appcompat-v7:27.0.2'

以前是

implementation 'com.android.support:appcompat-v7:27.1.0'

这也可以通过添加支持设计依赖来解决版本 27.1.0 或更高版本到您的应用程序级别 build.gradle 如下:

implementation 'com.android.support:design:27.1.0'

这篇关于错误:程序类型已经存在:android.support.design.widget.CoordinatorLayout$Behavior的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆