When will Robolectric be compatible with Android SDK 29? Did I upgraded too early by changing targetSdkVersion
and compileSdkVersion
to 29?
With Robolectric 4.3.1 we can use the following alternatives:
If we like to run our test with Java 8, we can:
Like this:
@RunWith(AndroidJUnit4::class)
@Config(sdk = [Build.VERSION_CODES.P])
class LoginRobolectricTest {
//...
}
app/src/test/resources
folder with the SDK we like to run, by example:sdk=28
Latest Robolectric 4.3 already supports Android Q (https://github.com/robolectric/robolectric/releases)
Create a robolectric.properties
file inside the app/src/test/resources
directory with the following line:
sdk=28
This will force Robolectric to use API 28 instead of 29.
If anyone is wondering, the solution for me was to annotate my test classes with
@Config(sdk = Build.VERSION_CODES.O_MR1)