Сбой тестов в эспрессо с устройствами под Lollipop (сбой: запуск инструментария завершился неудачно из-за ошибки java.lang.IllegalAccessError)

Я пытаюсь запустить экспресс-тесты с помощью Spoon в проекте multidex. Тесты выполняются без проблем на устройствах/ВМ с Lollipop или Marshmallow, но они не работают на устройствах Lollipop.

Есть несколько других вопросов об этой проблеме в stackoverflow, и все решения говорят о том, чтобы избежать дублирования библиотек в конфигурации зависимостей Gradle, но я не смог найти ни их, ни какую-либо другую проблему.

Это результат make a ./gradlew -q :project:dependencies

_debugAndroidTestApk - ## Internal use, do not manually configure ##
+--- com.android.support.test:runner:0.4.1
|    +--- com.android.support.test:exposed-instrumentation-api-publish:0.4.1
|    \--- junit:junit:4.12
|         \--- org.hamcrest:hamcrest-core:1.3
+--- com.android.support.test:rules:0.4.1
|    \--- com.android.support.test:runner:0.4.1 (*)
+--- com.android.support.test.espresso:espresso-contrib:2.2.1
|    +--- com.android.support.test.espresso:espresso-core:2.2.1
|    |    +--- com.squareup:javawriter:2.1.1
|    |    +--- com.android.support.test:runner:0.4.1 (*)
|    |    +--- com.android.support.test:rules:0.4.1 (*)
|    |    +--- org.hamcrest:hamcrest-library:1.3
|    |    |    \--- org.hamcrest:hamcrest-core:1.3
|    |    +--- org.hamcrest:hamcrest-integration:1.3
|    |    |    \--- org.hamcrest:hamcrest-library:1.3 (*)
|    |    +--- com.google.code.findbugs:jsr305:2.0.1
|    |    +--- javax.annotation:javax.annotation-api:1.2
|    |    +--- com.android.support.test.espresso:espresso-idling-resource:2.2.1
|    |    \--- javax.inject:javax.inject:1
|    \--- com.google.android.apps.common.testing.accessibility.framework:accessibility-test-framework:2.0
|         \--- org.hamcrest:hamcrest-core:1.3
+--- com.android.support.test.espresso:espresso-core:2.2.1 (*)
+--- com.android.support.test.espresso:espresso-intents:2.2.1
|    \--- com.android.support.test.espresso:espresso-core:2.2.1 (*)
+--- com.android.support:multidex-instrumentation:1.0.1
+--- com.squareup.spoon:spoon-client:1.2.0
\--- project :multidextest
 +--- com.android.support:multidex:1.0.1
 \--- com.android.support.test:runner:0.4.1 (*)

Это наши зависимости:

dependencies {
    compile project(':MemorizingTrustManager')
    compile project(':widgets')
    compile fileTree(dir: 'libs')
    compile 'com.android.support:multidex:1.0.1'
    compile "org.igniterealtime.smack:smack-android-extensions:4.1.3"
    compile "org.igniterealtime.smack:smack-experimental:4.1.3"
    compile "org.igniterealtime.smack:smack-tcp:4.1.3"
    compile 'com.android.support:support-v4:23.0.1'
    compile 'com.android.support:appcompat-v7:23.0.1'
    compile 'com.android.support:design:23.0.1'
    compile 'com.android.support:cardview-v7:23.0.1'
    compile 'com.android.support:recyclerview-v7:23.0.1'
    compile 'com.jakewharton:butterknife:6.1.0'
    compile 'com.squareup:otto:1.3.7'
    compile 'com.squareup.okhttp:okhttp:2.4.0'
    compile 'com.squareup.okhttp:okhttp-urlconnection:2.4.0'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'uk.co.chrisjenx:calligraphy:2.1.0'
    compile 'com.google.dagger:dagger:2.0.1'
    apt 'com.google.dagger:dagger-compiler:2.0.1'
    provided 'org.glassfish:javax.annotation:10.0-b28'
    compile 'com.squareup.retrofit:retrofit:1.9.0'
    compile 'com.github.pedrovgs:renderers:2.0.3'
    compile 'com.getbase:floatingactionbutton:1.10.0'
    compile 'fr.avianey.com.viewpagerindicator:library:2.4.1@aar'
    compile 'com.google.android.gms:play-services-analytics:8.1.0'
    compile 'com.google.android.gms:play-services-gcm:8.1.0'
    compile "com.mixpanel.android:mixpanel-android:4.6.4"
    compile 'org.apmem.tools:layouts:1.8@aar'
    compile('com.crashlytics.sdk.android:crashlytics:2.3.2@aar') {
        transitive = true;
    }
    testCompile 'junit:junit:4.12'
    testCompile 'org.mockito:mockito-all:1.10.19'
    testCompile 'org.hamcrest:hamcrest-all:1.3'
    androidTestCompile ('com.android.support.test:runner:0.4.1') {
        exclude module: 'support-annotations'
    }
    androidTestCompile ('com.android.support.test:rules:0.4.1') {
        exclude module: 'support-annotations'
    }
    androidTestCompile ('com.android.support.test.espresso:espresso-contrib:2.2.1') {
        exclude module: 'support-annotations'
        exclude module: 'support-v4'
        exclude module: 'support-v13'
        exclude module: 'recyclerview-v7'
        exclude group: 'javax.inject'
    }
    androidTestCompile ('com.android.support.test.espresso:espresso-core:2.2.1') {
        exclude module: 'support-annotations'
        exclude group: 'javax.inject'
    }
    androidTestCompile ('com.android.support.test.espresso:espresso-intents:2.2.1') {
        exclude module: 'support-annotations'
    }
    androidTestCompile('com.android.support:multidex-instrumentation:1.0.1') {
        exclude group: 'com.android.support', module: 'multidex'
    }
    androidTestCompile "com.squareup.spoon:spoon-client:1.2.0"
    androidTestCompile project(':multidextest')
}

И, наконец, трассировка стека с проблемой:

11:18:24 D/Device: Uploading file onto device 'emulator-5554'
2015-11-17 11:18:49 [SDR.run] About to actually run tests for [emulator-5554]
11:18:49 I/RemoteAndroidTest: Running am instrument -w -r  -e class com.redbooth.newredbooth.presentation.tests.collaboration.dashboard.DashboardActivityTest com.project.debug.test/com.project.multidextest.MultidexAndroidJUnitRunner on Nexus_One_API_15 [emulator-5554]
11:18:49 I/InstrumentationResultParser: test run failed: 'Instrumentation run failed due to 'java.lang.IllegalAccessError''
2015-11-17 11:18:49 [STRL.testRunStarted] testCount=0 runName=com.project.debug.test
2015-11-17 11:18:49 [STRL.testRunFailed] errorMessage=Instrumentation run failed due to 'java.lang.IllegalAccessError'
2015-11-17 11:18:49 [STRL.testRunEnded] elapsedTime=0
11:18:49 I/XmlResultReporter: XML test result file generated at /Users/disaster/Repositorios/Project/android/project/build/custom-report-dir/debug/junit-reports/emulator-5554.xml. Total tests 0, 
2015-11-17 11:18:50 [SDR.run] About to grab screenshots and prepare output for [emulator-5554]
2015-11-17 11:18:50 [SDR.pullScreenshotsFromDevice] Internal path is /data/data/com.project.debug/app_spoon-screenshots
2015-11-17 11:18:50 [SDR.pullScreenshotsFromDevice] External path is /mnt/sdcard/app_spoon-screenshots
2015-11-17 11:18:50 [SDR.pullScreenshotsFromDevice] Pulling screenshots from external dir on [emulator-5554]
2015-11-17 11:18:50 [SDR.pullScreenshotsFromDevice] Pulling screenshots from internal dir on [emulator-5554]
2015-11-17 11:18:50 [SDR.pullScreenshotsFromDevice] Done pulling screenshots from [emulator-5554]
2015-11-17 11:18:50 [SDR.run] Moving screenshots to the image folder on [emulator-5554]
2015-11-17 11:18:50 [SDR.run] Generating animated gifs for [emulator-5554]
2015-11-17 11:18:50 [SDR.run] Done running for [emulator-5554]
2015-11-17 11:18:50 [SR.runTests] [emulator-5554] Execution done.
:project:spoonDebugAndroidTest FAILED

person Nescafemix    schedule 17.11.2015    source источник


Ответы (1)


Наконец, я нашел проблему >‹.

AndroidJUnitRunner совместим с Multidex, поэтому создавать альтернативный Runner не пришлось, о чем можно прочитать в последних сообщениях: https://plus.google.com/+OleksandrKucherenko/posts/i7qZdVEy3Ue

С другой стороны, у меня был модуль с новым раннером и некоторыми тестами, и это было не очень нужно. Я удалил модуль и снова настроил testInstrumentationRunner как testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner', и проблема устранена.!

person Nescafemix    schedule 17.11.2015