Robolectric 4.3.1 失败并显示消息:Android 29 需要 Java 9(有 Java 1)
Robolectric 4.3.1 fails with message: Android 29 requires Java 9 (have Java 1)
我正在尝试通过 robolectric 运行 我的 android 测试,但它收到以下错误消息:
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)
...
我安装的 JDK 版本是 13.
我已将 android.enableUnitTestBinaryResources=true
添加到 gradle.properties 并在 build.gradle 中配置了 testOptions.unitTests.includeAndroidResources = true
。
我的测试 运行ner 是 AndroidJUnit4::class
,如 Robolectric 4.x 文档中所述。
Robolectric 目前只能识别 JDK 具有正确格式的版本字符串 (X.XX.XX):
https://github.com/robolectric/robolectric/issues/5303#issuecomment-547029317.
此外,只有 Gradle 6.0 及更高版本才支持使用 JDK 13 构建。
订购 Robolectric 版本时出现问题,特别是 4.3.1。只需将 Robolectric 版本升级到 4.5.1 或更高版本。
implementation "org.robolectric:robolectric:4.5.1"
谢谢。
我正在尝试通过 robolectric 运行 我的 android 测试,但它收到以下错误消息:
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)
...
我安装的 JDK 版本是 13.
我已将 android.enableUnitTestBinaryResources=true
添加到 gradle.properties 并在 build.gradle 中配置了 testOptions.unitTests.includeAndroidResources = true
。
我的测试 运行ner 是 AndroidJUnit4::class
,如 Robolectric 4.x 文档中所述。
Robolectric 目前只能识别 JDK 具有正确格式的版本字符串 (X.XX.XX): https://github.com/robolectric/robolectric/issues/5303#issuecomment-547029317.
此外,只有 Gradle 6.0 及更高版本才支持使用 JDK 13 构建。
订购 Robolectric 版本时出现问题,特别是 4.3.1。只需将 Robolectric 版本升级到 4.5.1 或更高版本。
implementation "org.robolectric:robolectric:4.5.1"
谢谢。