Android gradle中的版本冲突
我有一个错误“程序类型已经存在:android.support.design.widget.CoordinatorLayout$Behavior 消息{kind=ERROR,text=Program type已存在:android.support.design.widget.CoordinatorLayout$Behavior,sources=[未知源文件],tool name=Optional.of(D8)}” 我想征求你的意见,我该如何处理这个问题 谢谢你的帮助Android gradle中的版本冲突,android,build.gradle,Android,Build.gradle,我有一个错误“程序类型已经存在:android.support.design.widget.CoordinatorLayout$Behavior 消息{kind=ERROR,text=Program type已存在:android.support.design.widget.CoordinatorLayout$Behavior,sources=[未知源文件],tool name=Optional.of(D8)}” 我想征求你的意见,我该如何处理这个问题 谢谢你的帮助 My gradle in a
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'}
}
我的项目级毕业生
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
}
}
您需要从espresso Core中排除支持库,如下所示:
androidTestImplementation('com.android.support.test.espresso:espresso-
core:3.0.2') {
exclude group: 'com.android.support', module: 'support-annotations'
}
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
您还需要确保您的appcompat
和design
库具有相同的最新版本,如下所示:
androidTestImplementation('com.android.support.test.espresso:espresso-
core:3.0.2') {
exclude group: 'com.android.support', module: 'support-annotations'
}
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
我想问一下这两行(androidTestImplementation)是做什么的,因为这些行是在创建这个项目时自动生成的。谢谢@George espresso core对支持库有一些内部依赖,在gradle构建期间可能会泄漏到您的依赖中。添加这几行确保它们被排除。@George添加这一行后,它对您有效吗?只是尝试了一下,但不起作用。显示了相同的错误。@George您是否可以删除
应用插件:“com.google.gms.google services”
,因为您已经声明了特定的库?