While I run JUnit tests, it throws the following error:
java.lang.IllegalAccessError: tried to access field org.robolectric.annotation.Config$Builder.sdk from class org.robolectric.RobolectricTestRunner$1
It seems that there's sth wrong here in the RobolectricTestRunner.java(3.6.1)
The code in the screenshot is in the robolectric-3.6.1-resources.jar
Environment:
- JUnit: 4.12
- Robolectric 3.6.1
- Android Gradle Plugin: 2.3.3
- Android Studio: 3.0.1
- OS: MacOS 10.13.2
Anyone can help me? thks
At last, I have figured out what's wrong. In the
app/build.gradle
, I had the following dependencies:I had the
shadows-multidex
dependencies in version 3.2.2, which had theorg.robolectric:robolectric-annotations:3.2.2
internal. So, after I changed the version ofshadow-multidex
to 3.6.1 as the robolectric version, everything was fine!