简体   繁体   English

使用shadowOf方法时Robolectric编译错误

[英]Robolectric compilation error while using shadowOf method

I am using Robolectric 1.2 in an Andorid 2.3.3 project (API 10) 我在Andorid 2.3.3项目(API 10)中使用Robolectric 1.2
It throws the below compilation error, when using shadowOf method 当使用shadowOf方法时,它会抛出以下编译错误

ShadowView shadowView = Robolectric.shadowOf(view);

error: cannot access ObjectAnimator 错误:无法访问ObjectAnimator

But the error is gone, if I change the android sdk to API 11 and above 但是如果我将android sdk更改为API 11及更高版本,则错误消失了

I'm still having this issue with 2.2. 2.2我仍然遇到这个问题。 I got around this by 我绕过这个

import static org.robolectric.Robolectric.shadowOf_;
...
ShadowView shadowView = Robolectric.shadowOf_(view);

If anyone could provide some insight why this works, that would be awesome! 如果有人能够提供一些有用的信息,那么这将是非常棒的!

After some analysis, found that it is a bug in robolectric. 经过一番分析,发现它是robolectric中的一个bug。

For now, using 2.0-alpha-1 seems to fix the issue. 目前,使用2.0-alpha-1似乎解决了这个问题。

Here is the github issue created for the issue 这是为该问题创建的github问题
https://github.com/pivotal/robolectric/issues/431 https://github.com/pivotal/robolectric/issues/431

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Robolectric:找不到Shadows.shadowOf(Context)方法 - Robolectric: Shadows.shadowOf(Context) method not found Robolectric测试在shadowOf上失败 - Robolectric tests fail on shadowOf shadowOf()在Robolectric-3.0-rc3.jar中未定义 - shadowOf() undefined in Robolectric-3.0-rc3.jar 使用Eclipse使用Ant构建运行robolectric时遇到java.lang.ClassCastException错误 - Getting java.lang.ClassCastException error while running robolectric using ant build using eclipse 使用Dagger 2(Robolectric和Mockito)时进行单元测试 - Unit testing while using Dagger 2 (Robolectric and Mockito) 如何在使用Robolectric时计算测试覆盖率 - How to calculate test coverage while using Robolectric 使用 Robolectric 测试 ActionBarActivity 时出错 - Error when using Robolectric to test an ActionBarActivity 由于MediaPlayer的prepareAsync()方法,在Robolectric中进行单元测试回放时失败 - Failure while unit testing playback in Robolectric because of prepareAsync() method of MediaPlayer Robolectric PowerMock运行测试时出现java.lang.NoClassDefFoundError错误 - Robolectric PowerMock java.lang.NoClassDefFoundError error while running a test 使用 Robolectric 3.6.1 时出现 java.lang.IllegalAccessError - java.lang.IllegalAccessError while using Robolectric 3.6.1
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM