我有一个android studio项目,它具有以下与测试相关的依赖项:
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation fileTree(include: ['*.aar'], dir: 'libs')
// Core library
androidTestImplementation 'androidx.test:core:1.1.0'
// AndroidJUnitRunner and JUnit Rules
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test:rules:1.1.1'
// Assertions
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test.ext:truth:1.1.0'
androidTestImplementation 'com.google.truth:truth:0.42'
// Espresso dependencies
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-accessibility:3.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-web:3.1.1'
androidTestImplementation 'androidx.test.espresso.idling:idling-concurrent:3.1.1'
// The following Espresso dependency can be either "implementation"
// or "androidTestImplementation", depending on whether you want the
// dependency to appear on your APK's compile classpath or the test APK
// classpath.
androidTestImplementation 'androidx.test.espresso:espresso-idling-resource:3.1.1'
仍然Android Studio无法导入@RunWith批注。使用andoridx的API 28设计库时遇到了相同的问题。我相信即使要求开发人员使用androidx库,androidx仍然很烂!
我的gradle工具版本为“ 3.3.2”,而android studio稳定版本为 3.3.2
答案 0 :(得分:0)
将此依赖项添加到您的build.gradle
应用模块:
testImplementation 'junit:junit:4.12'
androidTestImplementation 'junit:junit:4.12'
答案 1 :(得分:0)
您确定自己的构建版本正确吗?我遇到了同样的问题,切换到 select LAST_DAY(to_date(regexp_replace('opimus_rise_issue_command_201912.txt', '[^0-9]', '') ||'01','yyyymmdd')) from dual;
构建变体可以让我正确添加导入
答案 2 :(得分:0)
添加以下依赖项:
testImplementation 'junit:junit:4.12'
androidTestImplementation 'junit:junit:4.12'
并确保您位于 androidTest包中,并同时使用 debug 构建变体