首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >频域java.lang.NoSuchFieldException: sSystem

频域java.lang.NoSuchFieldException: sSystem
EN

Stack Overflow用户
提问于 2017-05-16 10:58:46
回答 3查看 1K关注 0票数 4

在使用robolectric执行UnitTest时,我会收到错误。

java.lang.NoSuchFieldException: sSystem

请给我一个建议。

描述

综合频偏误差

代码语言:javascript
复制
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版本

代码语言:javascript
复制
compileSdkVersion 25
buildToolsVersion "25.0.2"
minSdkVersion 15
targetSdkVersion 25
testCompile 'org.robolectric:robolectric:3.2.2'
EN

回答 3

Stack Overflow用户

发布于 2018-09-16 12:57:11

由于以前的存储库下载失败,我也遇到了同样的问题。当我以sdk 23为目标时,我删除了触发重新下载并修复此问题的6.0.1_r3-robolectric-r1目录。

rm -rf /home/user/.m2/repository/org/robolectric/android-all/6.0.1_r3-robolectric-r1

票数 4
EN

Stack Overflow用户

发布于 2017-12-08 10:56:49

我在科特林考试中有过这样的经历,并通过打开我的考试课修正了这个问题:

代码语言:javascript
复制
@RunWith(RobolectricTestRunner::class)
@Config(sdk = [23], constants = BuildConfig::class)
open class MyExampleTest {

应用于java,这意味着您的测试类不应该是最终

票数 1
EN

Stack Overflow用户

发布于 2020-05-15 10:17:00

以前失败的存储库下载可能会导致此问题。·删除/home/user/.m2/repository/org/robolectric/android-all.中现有的机器人电气版本·重新运行您的测试(在此过程中,将重新下载“频域”)。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43999587

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档