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:
Anyone can help me? thks
At last, I have figured out what's wrong. In the app/build.gradle
, I had the following dependencies:
testCompile 'junit:junit:4.12'
testCompile 'org.assertj:assertj-core:2.6.0'
testCompile 'org.robolectric:robolectric:3.6.1'
testCompile 'org.robolectric:shadows-multidex:3.2.2'
I had the shadows-multidex
dependencies in version 3.2.2, which had the org.robolectric:robolectric-annotations:3.2.2
internal. So, after I changed the version of shadow-multidex
to 3.6.1 as the robolectric version, everything was fine!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.