gpt4 book ai didi

android - 无法解析符号 'ActivityTestRule'

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

我正在学习使用 espresso 来测试我的应用程序,但是 ActivityTestRule 总是无法解决。这是我的 app/build.gradle 配置,我确定我将测试类放在 src/androidTest 中。

非常感谢您的帮助!!

enter image description here

apply plugin: 'com.android.application'

android {
compileSdkVersion 27
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.android.teatime"
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'
}
}
}

dependencies {
compile 'com.android.support:design:27.1.1'
compile 'com.android.support:support-annotations:27.1.1'
compile 'com.google.android.gms:play-services-appindexing:9.8.0'
// Testing-only dependencies
androidTestCompile 'com.android.support:support-annotations:27.1.1'
androidTestCompile 'com.android.support.test.espresso:espresso-core:3.0.2'
androidTestCompile 'com.android.support.test:runner:1.0.2'
androidTestCompile 'com.android.support.test.espresso:espresso-contrib:3.0.2'
androidTestCompile 'com.android.support.test:rules:1.0.2'
}

最佳答案

我希望这对你有用。

使用

androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'

代替

androidTestCompile 'com.android.support.test.espresso:espresso-core:3.0.2'
androidTestCompile 'com.android.support.test:runner:1.0.2'

关于android - 无法解析符号 'ActivityTestRule',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50595971/

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