gradle中的版本冲突

时间:2018-05-22 02:40:07

标签: android build.gradle

我收到错误"程序类型已存在:android.support.design.widget.CoordinatorLayout $ Behavior 消息{kind = ERROR,text =程序类型已存在:android.support.design.widget.CoordinatorLayout $ Behavior,sources = [未知源文件],工具名称= Optional.of(D8)}"

我想征求你的意见,我可以用这个问题做些什么。

感谢您的帮助。

My gradle in app level

    apply plugin: 'com.android.application'
//apply plugin: 'com.google.gms.google-services'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.gtlab.asap"
        minSdkVersion 15
        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'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support:design:27.0.2'
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    implementation 'com.google.firebase:firebase-core:15.0.2'
    implementation 'com.google.firebase:firebase-database:15.0.0'
    implementation 'com.google.firebase:firebase-messaging:15.0.2'
    implementation 'com.google.firebase:firebase-auth:15.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'){ exclude group: 'com.android.support', module: 'support-annotations'}
}

我的项目级gradle

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'
        classpath 'com.google.gms:google-services:3.3.1'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

1 个答案:

答案 0 :(得分:1)

您需要从espresso-Core中排除支持库,如下所示:

 androidTestImplementation('com.android.support.test.espresso:espresso- 
    core:3.0.2') {
        exclude group: 'com.android.support', module: 'support-annotations'
 }

您还需要确保您的appcompatdesign库具有相同的最新版本,如下所示:

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