Тест Robolectric 4.0.2 не выполняется в Gradle 3.2.1 с NoSuchMethodError: setUseLegacyResources (Z) V - PullRequest
0 голосов
/ 11 декабря 2018

Я обновил версию своего плагина Gradle с 2.3.3 до 3.2.1, и после этого мой робототехнический тест не прошел.Поэтому я обновляю версию robolectric до 4.0.2 с учетом изменений в Документация .

Но все же все мои тесты не могут быть выполнены с этой ошибкой:

java.lang.NoSuchMethodError: org.robolectric.RuntimeEnvironment.setUseLegacyResources(Z)V

    at org.robolectric.android.internal.ParallelUniverse.setResourcesMode(ParallelUniverse.java:81)
    at org.robolectric.RobolectricTestRunner.configureSandbox(RobolectricTestRunner.java:235)
    at org.robolectric.internal.SandboxTestRunner$2.evaluate(SandboxTestRunner.java:230)
    at org.robolectric.internal.SandboxTestRunner.runChild(SandboxTestRunner.java:130)
    at org.robolectric.internal.SandboxTestRunner.runChild(SandboxTestRunner.java:42)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.robolectric.internal.SandboxTestRunner$1.evaluate(SandboxTestRunner.java:84)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
    at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.intellij.rt.execution.application.AppMainV2.main(AppMainV2.java:131)

Это то, что я пробовал до сих пор, но ничего не работает.

1. https://github.com/robolectric/robolectric/issues/4271

2. Robolectric: NullPointerException в setupActivity ()

3. https://github.com/robolectric/robolectric/issues/2579

Я уже подал вопрос

Буду признателен за любую помощь.

1 Ответ

0 голосов
/ 26 февраля 2019

Решено этим ответом на мою проблему.

. Конфигурация Gradle собирает разные версии зависимостей робоэлектрических систем.

Ожидается, что нам не нужно явно зависеть от ресурсов или ядра теней.так как те будут принесены непереходным.Поэтому попробуйте следующее

robolectricVersion = '4.0.2'
robolectric : "org.robolectric:robolectric:${robolectricVersion}",
shadowsSupport : "org.robolectric:shadows-support-v4:${robolectricVersion}",
shadowsMultidex: "org.robolectric:shadows-multidex:${robolectricVersion}",
...