Robolectric does not support API level 28

北城以北 提交于 2019-12-05 01:10:52

To complete Algar's answer, you can bypass temporarily this error (meanwhile Robolectric fix this issue) by annotating your test class like that :

@RunWith(RobolectricTestRunner::class)
@Config(sdk = [Build.VERSION_CODES.O_MR1])
class YourUnitTests {

...

}

It will force Robolectric using Android API 27.

Second edit: This has graduated from snapshot and is now available with

testImplementation 'org.robolectric:robolectric:4.0-beta-1'

i.e. you no longer need the maven snapshot line.


Edit: This is now fixed and available in the snapshot build. In your gradle build file (app level) add

repositories {
    maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}

and

dependencies {
    testImplementation 'org.robolectric:robolectric:4.0-alpha-3-SNAPSHOT'
}

Now that this issue is updated with info from a contributor it seems like there will be a new 4.0 alpha release that fixes the issue within this week.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!