我在Android Studio2.2预览版1中创建了一个新项目,带有Android应用程序和后端模块以及Google Messaging。这是应用程序文件:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.xxx.xxx"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha1'
compile 'com.google.android.gms:play-services-gcm:9.0.0'
testCompile 'junit:junit:4.12'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support:support-annotations:23.4.0'
compile project(path: ':backend', configuration: 'android-endpoints')
}但它给人的是:
错误:与依赖项'com.google.code.findbugs:jsr305‘冲突。app (1.3.9)和测试app (2.0.1)的解析版本不同。详情请参见http://g.co/androidstudio/app-test-app-conflict。
我是Android新手,找不到这个错误是什么。我该如何修复它?
发布于 2016-05-21 08:45:58
在应用程序的build.gradle中添加以下内容:
android {
configurations.all {
resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
}
}强制Gradle只编译您为所有依赖项声明的版本号,而不管依赖项声明了哪个版本号。
发布于 2016-12-05 16:49:48
这要归功于浓缩咖啡。您可以将以下内容添加到您的应用程序build.grade中以缓解此问题。
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2') {
exclude group: 'com.google.code.findbugs'
}发布于 2017-07-20 05:01:08
方法1:我删除了自动包含在新项目中的androidTestCompile on espresso-core行。然后我的Android Studio编译干净了。
模块在"build.gradle ( androidTestCompile :app)“中:
dependencies {
...
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
...
}我不知道这个删除是否会有任何问题,但它肯定适用于我目前的项目。
方法2:在findbugs上添加排除也是有效的:
dependencies {
...
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
exclude group: 'com.google.code.findbugs'
})
...
}方法三:使用特定版本强制编译:
(在下面我强制它使用更高的版本进行编译。)
dependencies {
...
androidTestCompile 'com.google.code.findbugs:jsr305:3.0.0'
...
}https://stackoverflow.com/questions/37347326
复制相似问题