首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >由于Android Marshmallow上的“java.lang.NoClassDefFoundError”,检测运行失败

由于Android Marshmallow上的“java.lang.NoClassDefFoundError”,检测运行失败
EN

Stack Overflow用户
提问于 2018-06-09 04:34:31
回答 1查看 425关注 0票数 1

我试图在Android6.0(API23)设备(模拟器和物理设备)上运行gradle Task :app:connectedDevDebugAndroidTest,但遇到了错误:

代码语言:javascript
复制
> Task :app:processDevDebugGoogleServices
Parsing json file: /Users/<name>/Projects/mobile-app-android/app/google-services.json
Starting 0 tests on Nexus_4_API_23(AVD) - 6.0
Tests on Nexus_4_API_23(AVD) - 6.0 failed: Instrumentation run failed due to 'java.lang.NoClassDefFoundError'

com.android.builder.testing.ConnectedDevice > No tests found.[Nexus_4_API_23(AVD) - 6.0] FAILED 
No tests found. This usually means that your test classes are not in the form that your test runner expects (e.g. don't inherit from TestCase or lack @Test annotations).

> Task :app:connectedDevDebugAndroidTest FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:connectedDevDebugAndroidTest'.
> There were failing tests. See the report at: file:///Users/<name>/Projects/mobile-app-android/app/build/reports/androidTests/connected/flavors/DEV/index.html

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

我试着找出问题的不同原因。此错误仅在Android6.0上弹出,仅当在终端中运行./gradlew connectedDevDebugAndroidTest (仪器测试)时出现。我最近在app/build.gradle中升级了一些测试库

代码语言:javascript
复制
testImplementation 'junit:junit:4.12'
testImplementation 'org.robolectric:robolectric:3.7.1'
testImplementation 'org.robolectric:shadows-support-v4:3.0'
testImplementation ('com.squareup.assertj:assertj-android:1.1.1') {
    exclude group: 'com.android.support', module: 'support-annotations'
}
testImplementation 'org.mockito:mockito-core:2.16.0'

androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test:rules:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
androidTestImplementation ('com.android.support.test.espresso:espresso-contrib:2.2.2') {
    exclude group: 'com.android.support', module: 'appcompat'
    exclude group: 'com.android.support', module: 'support-v4'
    exclude group: 'com.android.support', module: 'recyclerview-v7'
}
androidTestImplementation 'com.google.guava:guava:23.0'  // Needed for EspressoTestRule

androidTestImplementation 'org.mockito:mockito-android:2.16.0'
androidTestImplementation 'com.github.fabioCollini:DaggerMock:0.8.4'
androidTestImplementation 'com.github.andrzejchm.RESTMock:android:0.1.3'
androidTestImplementation('com.squareup.okhttp3:mockwebserver:3.8.1') {
    exclude module: 'bcprov-jdk15on'
    exclude module: 'okhttp'  // See: https://github.com/square/okhttp/issues/679
}

androidTestImplementation 'org.skyscreamer:jsonassert:1.4.0'

我怀疑最新版本的mockitoespresso中的某些东西破坏了某些东西,但我不确定。

EN

回答 1

Stack Overflow用户

发布于 2018-07-10 11:28:17

对于特定的设备,我偶尔会收到“找不到测试”的错误,清理项目,关闭Android Studio,然后重新启动它似乎可以修复它。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50768045

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档