I'm trying to run my android tests via robolectric, but it get the following error message:
at.guger.moneybook.data.repository.AccountsRepositoryTest STANDARD_ERROR
[Robolectric] WARN: Android SDK 16 requires Java 8 (have Java 1). Tests won't be run on SDK 16 unless explicitly requested.
[Robolectric] WARN: Android SDK 17 requires Java 8 (have Java 1). Tests won't be run on SDK 17 unless explicitly requested.
[Robolectric] WARN: Android SDK 18 requires Java 8 (have Java 1). Tests won't be run on SDK 18 unless explicitly requested.
[Robolectric] WARN: Android SDK 19 requires Java 8 (have Java 1). Tests won't be run on SDK 19 unless explicitly requested.
[Robolectric] WARN: Android SDK 21 requires Java 8 (have Java 1). Tests won't be run on SDK 21 unless explicitly requested.
[Robolectric] WARN: Android SDK 22 requires Java 8 (have Java 1). Tests won't be run on SDK 22 unless explicitly requested.
[Robolectric] WARN: Android SDK 23 requires Java 8 (have Java 1). Tests won't be run on SDK 23 unless explicitly requested.
[Robolectric] WARN: Android SDK 24 requires Java 8 (have Java 1). Tests won't be run on SDK 24 unless explicitly requested.
[Robolectric] WARN: Android SDK 25 requires Java 8 (have Java 1). Tests won't be run on SDK 25 unless explicitly requested.
[Robolectric] WARN: Android SDK 26 requires Java 8 (have Java 1). Tests won't be run on SDK 26 unless explicitly requested.
[Robolectric] WARN: Android SDK 27 requires Java 8 (have Java 1). Tests won't be run on SDK 27 unless explicitly requested.
[Robolectric] WARN: Android SDK 28 requires Java 8 (have Java 1). Tests won't be run on SDK 28 unless explicitly requested.
[Robolectric] WARN: Android SDK 29 requires Java 9 (have Java 1). Tests won't be run on SDK 29 unless explicitly requested.
at.guger.moneybook.data.repository.AccountsRepositoryTest > testUpdateAccount FAILED
java.lang.UnsupportedOperationException: Failed to create a Robolectric sandbox: Android SDK 29 requires Java 9 (have Java 1)
...
My installed JDK version is 13.
I've added android.enableUnitTestBinaryResources=true
to gradle.properties and configured testOptions.unitTests.includeAndroidResources = true
in build.gradle.
My test runner is AndroidJUnit4::class
as specified in the Robolectric 4.x docs.
There is an issue will order versions of Robolectric specifically 4.3.1. Simply upgrade the Robolectric Version to 4.5.1 or later.
implementation "org.robolectric:robolectric:4.5.1"
Thanks.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With