Robolectric找不到包含org.robolectric.ShadowsAdapter的阴影模块

时间:2016-10-27 09:21:22

标签: java android robolectric

我按照官方教程将robolectric添加到我现有的Android应用程序中。但是,当我试图进行简单的测试时,我得到了一个错误:

java.lang.RuntimeException: No shadows modules found containing a org.robolectric.ShadowsAdapter
at org.robolectric.Robolectric.instantiateShadowsAdapter(Robolectric.java:223)
at org.robolectric.Robolectric.getShadowsAdapter(Robolectric.java:48)
at org.robolectric.internal.ParallelUniverse.<init>(ParallelUniverse.java:39)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at
......

这是我的测试:

@RunWith(RobolectricTestRunner.class)
@Config(constants = BuildConfig.class, sdk = 23)
public class ExampleUnitTest {
    @Test
    public void test() throws Exception {
    }
}

build.gradle文件:

dependencies {
    ....
    testCompile 'junit:junit:4.12'
    testCompile "org.robolectric:robolectric:3.1.3"
}

1 个答案:

答案 0 :(得分:1)

尝试更改:

testCompile "org.robolectric:robolectric:3.1.3"

testCompile "org.robolectric:robolectric:3.1.2"