Не удалось запустить инструментарий из-за 'java.lang.NoClassDefFoundError' на Android Marshmallow - PullRequest
0 голосов
/ 08 июня 2018

Я пытаюсь запустить gradle Task :app:connectedDevDebugAndroidTest на устройстве Android 6.0 (API 23) (эмуляторе и физическом устройстве) и обнаружил ошибку:

> 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

Я пытался изолироватьразные причины проблемы.Эта ошибка появляется только для Android 6.0, только при запуске ./gradlew connectedDevDebugAndroidTest (тестирование инструментов) в терминале.Недавно я обновил некоторые тестовые библиотеки, в app/build.gradle:

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'

Я подозревал, что что-то в последней версии mockito или espresso сломало вещи, но я не уверен.

1 Ответ

0 голосов
/ 10 июля 2018

Иногда я получаю сообщение об ошибке «тесты не найдены» для определенных устройств, и очистка проекта, закрытие Android Studio и перезапуск, кажется, исправляют ее.

...