gpt4 book ai didi

robolectric java.lang.NoSuchFieldException : sSystem

转载 作者:行者123 更新时间:2023-12-03 22:26:58 24 4
gpt4 key购买 nike

使用 robolectric 进行 UnitTest 时,我收到错误

java.lang.NoSuchFieldException: sSystem



请给我一个建议。

enter image description here

描述

集成机器人电子错误
java.lang.RuntimeException: java.lang.RuntimeException: java.lang.NoSuchFieldException: sSystem

at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:332)
at org.robolectric.RobolectricTestRunner.runChild(RobolectricTestRunner.java:259)
at org.robolectric.RobolectricTestRunner.runChild(RobolectricTestRunner.java:41)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:199)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:119)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
Caused by: java.lang.RuntimeException: java.lang.NoSuchFieldException: sSystem
at org.robolectric.util.ReflectionHelpers.setStaticField(ReflectionHelpers.java:174)
at org.robolectric.shadows.ShadowAssetManager.reset(ShadowAssetManager.java:780)
at org.robolectric.Shadows.reset(Shadows.java:1644)
at org.robolectric.Robolectric.reset(Robolectric.java:35)
at org.robolectric.internal.ParallelUniverse.resetStaticState(ParallelUniverse.java:52)
at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:319)
... 19 more
Caused by: java.lang.NoSuchFieldException: sSystem
at java.lang.Class.getDeclaredField(Class.java:2070)
at org.robolectric.util.ReflectionHelpers.setStaticField(ReflectionHelpers.java:172)
... 24 more

重现步骤

Robolectric & Android 版本
compileSdkVersion 25
buildToolsVersion "25.0.2"
minSdkVersion 15
targetSdkVersion 25
testCompile 'org.robolectric:robolectric:3.2.2'

最佳答案

由于之前存储库下载失败,我遇到了同样的问题。
因为我的目标是 sdk 23 ,我删了6.0.1_r3-robolectric-r1触发重新下载并修复此问题的目录。
rm -rf /home/user/.m2/repository/org/robolectric/android-all/6.0.1_r3-robolectric-r1

关于robolectric java.lang.NoSuchFieldException : sSystem,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43999587/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com