Resources Notfoundexception

Android Resources$NotFoundException: Resource ID #0x7f030027

You can check your R file for Resources$NotFoundException: Resource ID #0x7f030027. It'll tell you which resource was creating the problem. As an alternative solution I think you might have setText or any content just an int.And as you know here compiler will look for corresponding resource value. So, just concat an empty string there as ""

Resources$NotFoundException when accessing an attribute as a color

For now I am considering this issue not solvable. Currently my approach is to use ?attr/primary_text_color and R.attr.primary_text_color everywhere possible.

Resources - NotFoundException when accessing literals

OK, the problem was in the gradle for the app module. There was a resConfig "zz" than can lead to this. Removing this line avoids all translation problems

Resources$NotFoundException Unable to find resource ID #0x7f080043 for Drawable

It might be due to the resource not having a file in the default folder (only in the xxhdpi and ldrtl-xxhdpi folders). The phone on which the app is crashing probably has a different density and the app is deployed/installed as an android app bundle (.aab) which enables google play to remove the resources it deems unnecessary (like this resource which would not be needed for that device given its different density) to reduce bundle size.

A workaround would be to copy that resource into your project (preferably with a different name to prevent other problems) and place it directly under the resources/drawables folder or in all drawables folders depending on its dimensions (if any). This should ensure it is present in all app bundles regardless of their target screen density.


Reply to comment:

Yes, indeed it is a bug though the android gradle plugin might have logged an error/warning in the build logs about the drawable in question not being provided for all densities. The rule/recommendation is to either have a drawable in the drawables folder or have copies (of proportional size) in each of the mdpi, hdpi, xhdpi, xxhdpi folders . In the case of this support library it only provided an xxhdpi version and probably at runtime the library uses the drawable only on xxhdpi devices. This is a 9 patch image so it can safely be copied to drawables without loss of quality.

Ideally most graphics would consist of vector drawables which can/should be placed in drawables without worrying about device density. Be mindful though about the vector drawable's width and height attributes as these will determine how big it will appear on screen and if these attributes are missing the size will be inferred from that of the view (wrap_content might result in the drawable not being visible).
Always be careful to provide resources for all device configurations (densities, screen orientations, ...) when using the aab format to deploy apps because the final archive downloaded by the device will probably have only resources for its density and/or the default ones (drawables, values). In the past (with the apk format) the android runtime would try to scale down a higher density drawable when a drawable for its density and a default one were not available. Now (with aab) that the higher density drawables are left out of the bundle this is no longer possible.

I also think it's a good practice not to use resources from 3rd party libraries directly (like referencing them from your layouts) because they can easily be renamed, moved or deleted (especially with dynamic gradle dependencies) and with the complex/non-deterministic android build system it might not become apparent before the published app crashes on a user's device. If you really need some resource in a library it might be better to copy it to your project. In general it's safer to rely as little as possible on things out of your control.

Getting Resources$NotFoundException on espresso when trying to access test resources

Found the solution for this. The issue at hand is that InstrumentationRegistry.getInstrumentation().targetContext will only be able to access what's included in the application being tested, so in this case I should use InstrumentationRegistry.getInstrumentation().context, which will be able to access test resources. For reference:

getTargetContext
Return a Context for the target application being instrumented. Note that this is often different than the Context of the instrumentation code, since the instrumentation code often lives is a different package than that of the application it is running against. See getContext() to retrieve a Context for the instrumentation code.

getContext
Return the Context of this instrumentation's package. Note that this is often different than the Context of the application being instrumentated, since the instrumentation code often lives is a different package than that of the application it is running against. See getTargetContext() to retrieve a Context for the target application.

from doc: https://developer.android.com/reference/android/app/Instrumentation

Resources$NotFoundException: Resource ID #0x7f040031

This is a common problem, you are using setText this method not only receives String also can receive the resource id (int), then in your code try to convert your int values to String to avoid this confusion.

    holder.txtdocumento.setText(""+beneficiarios.documento );
holder.txtedad.setText(""+beneficiarios.edad );

I'm assuming that documento and edad are integers.

UPDATE

Also you have to check that your view ids are in the layout that you are passing in this variablelayoutResourceId (listitem_beneficiarios.xml)

txtnombres,
txtapellidos,
txtdocumento,
txtedad,
txtparentesco,
txtfecha

UPDATE 2

You layout file should be in the res/layout/ folder , maybe you only have the layout inside /res/layout-??/ folder :) check this.

Resources$NotFoundException on some devices (setIcon)

I started getting a few of these reports after switching to app bundles. I always assumed they were from users who downloaded my apps from third-party APK mirror sites. So if the APK they downloaded doesn't match their device's density bucket, the app crashes as the relevant assets just aren't there.

how to resolve android.content.res.Resources$NotFoundException: Resource ID #0x7f070187 type #0x4 is not valid

Ensure the dimensions have a defined unit:

https://developer.android.com/guide/topics/resources/more-resources#Dimension

In your case do as next. Notice the dp postfix after each value:

<dimen name="pageMargin">20dp</dimen>
<dimen name="offset">30dp</dimen>


Related Topics



Leave a reply



Submit