Robolectric: Support android-24 target

Created on 13 Jul 2016  路  4Comments  路  Source: robolectric/robolectric

Using Robolectric 3.1.1 on an app with both targetSdkVersion and compileSdkVersion at 24:

java.lang.UnsupportedOperationException: Robolectric does not support API level 24.
    at org.robolectric.internal.SdkConfig.<init>(SdkConfig.java:46)
    at org.robolectric.RobolectricTestRunner.runChild(RobolectricTestRunner.java:173)
    at org.robolectric.RobolectricTestRunner.runChild(RobolectricTestRunner.java:63)
    [...]

The tests work fine if they are reverted to 23.

Seems like a predictable issue, but could not find it in the issue tracker.

simulation enhancement

Most helpful comment

If you don't want to write this above every file/method then you can add a file src/test/resources/robolectric.properties containing only: sdk=23

see Config Properties section in Configuring Robolectric docs.

All 4 comments

The temporary workaround that I am using is specifying SDK 23:

@RunWith(RobolectricTestRunner.class)
@Config(manifest = Config.NONE, sdk = 23)
public class SomeText {
    ...
}

@amitkot yes, that's what we're doing too. It's not really a workaround though, as this will break if you use any android-24 specific stuff.

If you don't want to write this above every file/method then you can add a file src/test/resources/robolectric.properties containing only: sdk=23

see Config Properties section in Configuring Robolectric docs.

Robolectric 3.2 supports API level 24.

Was this page helpful?
0 / 5 - 0 ratings