Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.IllegalStateException: there must have been some overlap for resourceIdToResName

I am trying to setup robolectric for my android app. My main code has a submodule and an external library, and i don't use Maven.

After following the steps to setup a robolectric project, when i try to run the test it gives the following error

java.lang.IllegalStateException: there must have been some overlap for resourceIdToResName! expected 3014 but got 3013
    at org.robolectric.res.MergedResourceIndex.merge(MergedResourceIndex.java:20)
    at org.robolectric.res.MergedResourceIndex.<init>(MergedResourceIndex.java:12)
    at org.robolectric.res.RoutingResourceLoader.<init>(RoutingResourceLoader.java:22)
    at org.robolectric.RobolectricTestRunner.createAppResourceLoader(RobolectricTestRunner.java:631)
    at org.robolectric.RobolectricTestRunner.getAppResourceLoader(RobolectricTestRunner.java:614)
    at org.robolectric.internal.ParallelUniverse.setupApplicationState(ParallelUniverse.java:35)
    at org.robolectric.RobolectricTestRunner.setupApplicationState(RobolectricTestRunner.java:414)
    at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:297)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
    at org.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:241)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    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)

Can anyone help me out with it! It tries to merge maps of resourceIdToResName from two sources, what are those sources?

Thanks

like image 330
rahul.garg Avatar asked Nov 13 '22 09:11

rahul.garg


1 Answers

This problem is probably caused by something in your main projects res folder, probably a layout xml file.

To analyse this delete files from your res folder until the test project runs. Compile errors in the main project while experimentally deleting res files to find the bad file won't stop your test project running but there must be no resource errors that prevent R.java being generated.

My problem was a mistake in a layout file as follows:

  <TextView android:id="@+android:id/actualValue"

After changing to

  <TextView android:id="@+id/actualValue"

everything worked fine.

like image 146
Martin Avatar answered Nov 15 '22 11:11

Martin