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

错误:程序类型已存在:android.support.design.widget.CoordinatorLayout$Behavior,android,kotlin,dagger-2,android-coordinatorlayout,Android,Kotlin,Dagger 2,Android Coordinatorlayout,我在构建项目时遇到以下错误。在这个项目中没有使用协调布局。刚刚作为依赖项添加到build.gradle中: 我使用的是安卓Studio 3.2金丝雀4 LogCat implementation 'com.android.support:appcompat-v7:27.1.0' implementation 'com.android.support:design:27.1.0' AGPBI:{“种类”:“错误”,“文本”:“程序类型已存在:android.support.design.wid

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

我使用的是安卓Studio 3.2金丝雀4

LogCat

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

implementation 'com.android.support:design:27.1.0'
AGPBI:{“种类”:“错误”,“文本”:“程序类型已存在:android.support.design.widget.CoordinatorLayout$Behavior”,“源”:[{}],“工具”:“D8”} :app:transformDexArchiveWithExternalLibsDexMergerForDebug失败 失败:生成失败,出现异常。 *出了什么问题: 任务“: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, . .

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

程序类型已存在: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"
}
我也面临同样的问题, 我将android支持设计依赖项添加到应用程序级别
build.gradle

添加以下内容:

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

格雷德尔。现在它为我工作

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

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'

使用最新的
supportLibrary
,版本
27.1.1
解决此问题。为我工作。(包括许多错误修复-

将所有依赖项更改为编译而不是实现,然后我重新构建了项目,没有出现错误。然后,我切换回实现,而不是将其保留为编译

使用

implementation 'com.android.support:appcompat-v7:27.1.1'
不要使用like

implementation 'com.android.support:appcompat-v7:27.+'
它可能会给你一个错误,不要使用比这个旧的版本

或者事件不这样做

implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1' 
等等。。。图书馆的数量,然后

implementation 'com.android.support:appcompat-v7:27.+'

同一个库但有不同的版本,它可能会给你一个错误。

因为android最新更新不支持“编译”关键字,所以在你的模块build.gradle文件中使用“实现”

并在build.gradle中彻底检查是否与下面的+符号相关

implementation 'com.android.support:support-v4:28.+'
如果有任何类似的依赖项,只需使用特定版本更新它们。 之后:

  • 同步梯度
  • 清理你的项目
  • 重建项目

  • 这可能是图书馆的原因,我面对它是因为滑翔

    是的

    implementation 'com.github.bumptech.glide:glide:4.7.1'
    
    所以我添加了
    排除组:“com.android.support”
    ,它就变成了

    implementation ('com.github.bumptech.glide:glide:4.7.1') {
            exclude group: "com.android.support"
        }
    

    如果这里提到的任何答案都不起作用,那么请转到文件>使捕获无效/重新启动

    我正在使用android studio 3.0 我将设计模式依赖项从26.0.1升级到27.1.1,现在错误消失了

    在渐变中添加以下内容
    implementation'com.android.support:design:27.1.1'

    确保这两个版本在应用程序级build.gradle文件中是相同的

        implementation 'com.android.support:appcompat-v7:27.1.1'
        implementation 'com.android.support:design:27.1.1'
    

    我想这应该能解决问题

    我也有这个问题;我决定这样做:

    configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == 'com.android.support') {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion '26.0.1'
            }
        }
      }
    }
    

    小心我的min SDk是26,你必须用你的更改它

    解决方案是删除以下依赖项:

    implementation 'com.android.support:design:26.1.0'
    
    将一般依赖项设置为:

    dependencies {
        implementation fileTree(include: ['*.jar'], dir: 'libs')
        //noinspection GradleCompatible
        implementation 'com.android.support:appcompat-v7:27.1.1'
        implementation 'com.android.support:support-compat:26.1.0'
        implementation 'com.android.support:multidex:1.0.3'    
        implementation 'com.android.support:support-v4:26.1.0'
        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'
        implementation 'com.facebook.android:audience-network-sdk:4.99.1'
    }
    

    我知道这是一个迟来的答案,但我有同样的问题,我的解决方案只是添加
    implementation'com.android.support:design:28.0.0
    或任何以上支持设计库

    我降低了支持级别

    previously it was
    implementation 'com.android.support:appcompat-v7:27.0.2'
    
    使用它

    implementation 'com.android.support:appcompat-v7:27.1.0'
    
    implementation 'com.android.support:design:27.1.0'
    
    它的工作状态很好

    重要更新 Android支持库在
    28.0.0
    之后不会更新。根据—

    这将是android.support下的最后一个功能版本 包装,并鼓励开发人员

    因此,请改用支持库。在您的情况下,设计库现在在material package中可用

    dependencies {
        implementation 'com.google.android.material:material:1.0.0' // instead of design
        implementation 'androidx.appcompat:appcompat:1.0.2' // instead of support-v7
    }
    
    我已经把最新的版本放在dependency中,你可以在阅读时在这里查看

    有用的帖子:


  • 就我个人而言,我在我的app/build.gradle中添加了以下内容:

    implementation "com.android.support:design:${rootProject.ext.supportLibVersion}"
    

    使用此语法,版本是动态的。

    将此添加到项目的
    渐变中。属性
    为我们修复了它:

    android.enableJetifier=true
    android.useAndroidX=true
    

    生成脚本应与application build.gradle依赖项匹配

    ext {
            buildToolsVersion = "27.0.3"
            minSdkVersion = 16
            compileSdkVersion = 27
            targetSdkVersion = 26
            supportLibVersion = "27.1.1"
        }
    
    
    dependencies {
        .................
        ...................
    
        implementation 'com.android.support:support-v4:27.1.0'
        implementation 'com.android.support:design:27.1.0'
        ................
        ...........
    }
    
    如果要降级依赖项,请同时降级supportLibVersion和buildToolsVersion。

    “程序类型已存在” 如果删除/build目录内容,则生成的二进制文件存在一些索引问题。就像你一样,他们帮助解决了这个问题,但也创造了许多其他问题。构建内容删除对所有人都有效。

    我也面临同样的问题。 但后来我意识到我使用的支持库版本不一样

    一旦我做了同样的事情,错误就消失了

    就你而言

    implementation 'com.android.support:appcompat-v7:27.1.0'
    implementation 'com.android.support:design:27.0.2'
    
    不一样,所以您刚刚将appcompat降级为

    implementation 'com.android.support:appcompat-v7:27.0.2'
    
    因此,你的问题解决了

    但若您可以将支持设计版本升级到

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

    转到放置其他库并删除重复库的目录。

    当一个库多次加载到gradle中时,可能会发生这种情况。通常通过其他连接的库

    build.gradle中删除实现此库

    previously it was
    implementation 'com.android.support:appcompat-v7:27.0.2'
    
    然后构建->清除项目

    implementation 'com.android.support:appcompat-v7:27.1.0'
    
    implementation 'com.android.support:design:27.1.0'
    
    您可以运行该程序集)