New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting resource not found exception #3324

Closed
vaibhavpali opened this Issue Aug 10, 2017 · 3 comments

Comments

Projects
None yet
3 participants
@vaibhavpali

vaibhavpali commented Aug 10, 2017

Description

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:
image

image

Robolectric version: 3.0
Android studio: 2.3.3
Gradle: 2.1.3

@leocabral

This comment has been minimized.

Show comment
Hide comment
@leocabral

leocabral Aug 22, 2017

@vp2601 please, follow these steps to make sure you have all set to run the tests

  1. include this into your module build gradle file
android {
 testOptions.unitTests.includeAndroidResources true
}
  1. add android.enableAapt2=false into gradle.properties..

  2. 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 commented Aug 22, 2017

@vp2601 please, follow these steps to make sure you have all set to run the tests

  1. include this into your module build gradle file
android {
 testOptions.unitTests.includeAndroidResources true
}
  1. add android.enableAapt2=false into gradle.properties..

  2. 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

😀

@brettchabot

This comment has been minimized.

Show comment
Hide comment
@brettchabot

brettchabot Aug 23, 2017

Contributor

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?

Contributor

brettchabot commented Aug 23, 2017

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?

@brettchabot

This comment has been minimized.

Show comment
Hide comment
@brettchabot

brettchabot Aug 30, 2017

Contributor

Please reopen if you are continuing to have problems. Please note there are some workarounds listed here:http://robolectric.org/getting-started/

Contributor

brettchabot commented Aug 30, 2017

Please reopen if you are continuing to have problems. Please note there are some workarounds listed here:http://robolectric.org/getting-started/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment