开发者

Robolectric Issue with ProgressBar

I keep getting a RuntimeException from Robolectric when it tries to invoke an onCreate for an activity that has a ProgressBar. I've localized the issue to this block in the layout xml file. As soon as I remove this and re-run the test, things work fine.

<ProgressBar android:id="@+android:id/progress_large"
  style="?android:attr/progressBarStyleLarge"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:layout_centerInParent="true"
  android:visibility="invisible"/>

Here is the full stack trace:

java.lang.RuntimeException: java.lang.RuntimeException: 16842752 is already defined with name: id/progress_large can't also call it: attr/theme
    at com.xtremelabs.robolectric.RobolectricTestRunner.createResourceLoader(RobolectricTestRunner.java:314)
    at com.xtremelabs.robolectric.RobolectricTestRunner.setupApplicationState(RobolectricTestRunner.java:268)
    at com.xtremelabs.robolectric.RobolectricTestRunner.internalBeforeTest(RobolectricTestRunner.java:219)
    at com.xtremelabs.robolectric.RobolectricTestRunner.methodBlock(RobolectricTestRunner.java:199)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.RuntimeException: 16842752 is already defined with name: id/progress_large can't also call it: attr/theme
    at com.xtremelabs.robolectric.res.ResourceExtractor.addRClass(ResourceExtractor.java:37)
   开发者_运维百科 at com.xtremelabs.robolectric.res.ResourceExtractor.addSystemRClass(ResourceExtractor.java:18)
    at com.xtremelabs.robolectric.res.ResourceLoader.<init>(ResourceLoader.java:59)
    at com.xtremelabs.robolectric.RobolectricTestRunner.createResourceLoader(RobolectricTestRunner.java:311)
    ... 17 more

I'm working of the github head (1.0-RC2) because I thought the ShadowProgressBar would help me out but it doesn't seem to have, but I might not be using it correctly.

I also thought the id or the style were causing the issue but removing them in the XML didn't stop the Exception.

Any help would be appreciated.

UPDATE

I changed the progress bar xml to this:

<ProgressBar 
  android:id="@+id/circle_progress_bar"
  style="@android:style/Widget.ProgressBar.Large.Inverse"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:layout_centerInParent="true"
  android:visibility="invisible" />

And it worked.


change

android:id="@+android:id/progress_large"

to

android:id="@+id/progress_large"

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜