Hello, could anyone help on below issue, I have set up the roboelectric into my workspace, however im getting below error:
android.content.res.Resources$NotFoundException: unknown resource 2131231855
at org.robolectric.shadows.ShadowAssetManager.getAndResolve(ShadowAssetManager.java:351)
at org.robolectric.shadows.ShadowAssetManager.getResourceText(ShadowAssetManager.java:70)
at android.content.res.AssetManager.getResourceText(AssetManager.java)
at android.content.res.Resources.getText(Resources.java:270)
at org.robolectric.shadows.ShadowResources.getText(ShadowResources.java:358)
at android.content.res.Resources.getText(Resources.java)
at android.content.res.Resources.getString(Resources.java:360)
at org.robolectric.shadows.ShadowContext.getString(ShadowContext.java:33)
at org.robolectric.shadows.ShadowContextWrapper.getString(ShadowContextWrapper.java:81)
at android.content.Context.getString(Context.java)
at com.example.wallet.WalletApplication.onCreate(WalletApplication.java:70)
at org.robolectric.internal.ParallelUniverse.setUpApplicationState(ParallelUniverse.java:140)
at org.robolectric.RobolectricTestRunner.setUpApplicationState(RobolectricTestRunner.java:433)
at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:240)
at org.robolectric.RobolectricTestRunner.runChild(RobolectricTestRunner.java:188)
at org.robolectric.RobolectricTestRunner.runChild(RobolectricTestRunner.java:54)
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:152)
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:117)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:262)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:84)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Basically in my WalletApplication.java file, it is getting failed in onCreate() method, while fetching string resource using getString() method of Context class.
Test file code is:


Robolectric version: 3.0
Android studio: 2.3.3
Gradle: 2.1.3
@vp2601 please, follow these steps to make sure you have all set to run the tests
android {
testOptions.unitTests.includeAndroidResources true
}
add android.enableAapt2=false into gradle.properties..
and make sure to use the latest AGP plugin version
i guess it should all be fine now...
also check these links below
https://issuetracker.google.com/issues/64107525
https://issuetracker.google.com/issues/63721209
馃榾
leocabral@ this seems like it could be a different issue. From the bug report older versions of AS Studio and gradle are being used.
@vp2601 could you please provide a sample project that reproduces this issue?
Please reopen if you are continuing to have problems. Please note there are some workarounds listed here:http://robolectric.org/getting-started/
Most helpful comment
@vp2601 please, follow these steps to make sure you have all set to run the tests
add
android.enableAapt2=falseinto gradle.properties..and make sure to use the latest AGP plugin version
i guess it should all be fine now...
also check these links below
https://issuetracker.google.com/issues/64107525
https://issuetracker.google.com/issues/63721209
馃榾