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.
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.
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.propertiescontaining only:sdk=23see Config Properties section in Configuring Robolectric docs.