gpt4 book ai didi

Android 版本 24.0.0 和 Espresso 2.0 gradle 异常

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:01:57 24 4
gpt4 key购买 nike

我正在尝试在我的应用程序中使用 Espresso 2.0,以测试 UI 元素。但是gradle不允许这样做。它给了我这条信息

Error:Conflict with dependency 'com.android.support:support-annotations'. Resolved versions for app (24.0.0) and test app (23.1.1) differ. See http://g.co/androidstudio/app-test-app-conflict for details.

这是我的gradle 文件

apply plugin: 'com.android.application'

android {
compileSdkVersion 24
buildToolsVersion "24.0.0"

defaultConfig {
applicationId "theo.testing.espressotutorial"
minSdkVersion 14
targetSdkVersion 24
versionCode 1
versionName "1.0"


}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

packagingOptions{
exclude 'LICENSE.txt'
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.0.0'

androidTestCompile 'com.android.support.test.espresso:espresso-core:2.0'

// Android JUnit Runner
androidTestCompile 'com.android.support.test:runner:0.5'
// JUnit4 Rules
androidTestCompile 'com.android.support.test:rules:0.5'
}

我应该更新测试运行程序吗?这让我很头疼。

谢谢,

西奥。

最佳答案

Espresso 具有导致这些问题的传递依赖项。您可以从 androidTest 依赖项中排除对 com.android.support 组的所有依赖项:

// Exclude Espresso's transitive dependencies to all packages in group com.android.support
configurations.androidTestCompile.dependencies.each { androidTestCompileDependency ->
androidTestCompileDependency.exclude group: 'com.android.support'
}

你应该使用 Espresso 2.2.2!一个完整的例子:

dependencies {

def espressoVersion = '2.2.2'
def testRunnerVersion = '0.5'

androidTestCompile "com.android.support.test:runner:${testRunnerVersion}"
androidTestCompile "com.android.support.test:rules:${testRunnerVersion}"
androidTestCompile "com.android.support.test.espresso:espresso-core:${espressoVersion}"
androidTestCompile "com.android.support.test.espresso:espresso-contrib:${espressoVersion}"
androidTestCompile "com.android.support.test.espresso:espresso-intents:${espressoVersion}"

configurations.androidTestCompile.dependencies.each { androidTestCompileDependency ->
androidTestCompileDependency.exclude group: 'com.android.support'
}
}

关于Android 版本 24.0.0 和 Espresso 2.0 gradle 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38181587/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com