记录Android 使用robolectric 异常

This is an old issue, but for future google searchers and perhaps interested parties that could work around this, it is worth mentioning that if you are using one of the more popular walk-throughs to set up JaCoCo + Robolectric + Espresso - https://medium.com/@rafael_toledo/setting-up-an-unified-coverage-report-in-android-with-jacoco-robolectric-and-espresso-ffe239aaf3fa - you will indeed be using "includeNoLocationClasses", so you will see this error with Java9+ and probably end up here. The workaround does work though, and the required modification (per the followup article on the setup guide I linked above) is:

tasks.withType(Test) {
    jacoco.includeNoLocationClasses = true
    jacoco.excludes = ['jdk.internal.*']
}

Gradle Test Executor is crashed with jacoco with-options includeNoLocationClasses on JDK 9 · Issue #5184 · gradle/gradle