Android Resources$NotFoundException: Resource ID #0x7f030027

别说谁变了你拦得住时间么 提交于 2019-11-26 22:12:47
Manmohan

You can check your R file for Resources$NotFoundException: Resource ID #0x7f030027. It'll tell you which resource was creating problem. As an alternative sollution 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 ""

I was getting this exception:

android.content.res.Resources$NotFoundException: Resource ID #0x7f02004f

I was calling PNG Icon from ...\app\src\main\res\drawable-21

When I put my PNG Icon into ...\app\src\main\res\drawable and I call it,
My problem goes away

BTW XML worked from \drawable-21

Had this same issue too.

But it turned out as I was moving things around in my IDE I wrongly moved a layout resource(xml) from the layout directory into layout-land.

It worked after I moved it back.

Hope this helps someone.

In my case error occured after update to Android Studio build: 3.0 Canary 6, i fixed it in downgradeing it to the previous version 3.0 Canary-5 and build tools canary-5.

The issue was related with some incompability with vector drawables on api 19 and below

EDIT: It's looks like that mentioned issue was resolved on Android Studio build: 3.0 Canary 7

For me, while creating layout file it landed in layout-land folder, hence the exception. Hope it will help someone.

I tried to move image files (png,jpg) from drawable-v24 to drawable

It solved the Problem

a) there could be an error in any of your resource xml files (strings, layouts, anim,etc..) and your.package.name.R cannot compile with that error

EX:

<string name="main_header">My problem wasn't in java it was in this string</string>

Error: apostrophe' needs to be preceeded by a backslash \

Correction:

<string name="main_header">My problem wasn\'t in java it was in this string</string>

or,

b) You imported the wrong "R" into your class. make sure you import your.package.name.R and not android.R

EX:

//You DO NOT want this, unless you are working directly with android's 
  resources, not your own in your project
import android.R

Correction:

// You want to reference your project's resources, not Android OS's
import your_package_name_here.R

Hope this helps, Happy Coding!

I was getting this error on on Android 4.2.2 but not on Android 5 and Android 6. Reason was I had put some vector icons (xml files for navigation drawer) in drawable-v21 folder because by default android generated navigation drawer icons e.g. ic_menu_gallery.xml were residing in drawable-v21 folder. Moving these xml files (which i generated and not default ones) to drawable folder solved my problem. Don't move default generated icons to drawable else it might cause duplicate exception.

I have just come across the same issue- cleaning and rebuilding the project solved the problem for me!

GigantoHK

Look at this link , maybe it will help you , it is the same problem. If the cleaning of project does not help you try to delete your r.java file it will be generated itself. Getting android.content.res.Resources$NotFoundException: exception even when the resource is present in android

If you're using vector drawable in the resource.xml which has a <layer-list> on API version 19 or lower you will get this exception

In my case I was using a custom style for my vertical scrollbar in scroll view like this:

 <ScrollView
        android:id="@+id/scroller"
        style="@style/scrollbar_shape_style"
  ..>

and my style was like:

 <style name="scrollbar_shape_style">
  ...

I changed the first part to this:

<ScrollView
    android:id="@+id/scroller"
    android:theme="@style/scrollbar_shape_style"

and added parent to the style like this:

<style name="scrollbar_shape_style" parent="LightTheme">

and problem solved.

You could be calling a string from project resources with

Resources().getSystem().getString( R.string.my_string_id)

which refers to global resources. To refer to your project resources do getString() directly from your activity:

this.getString(
  R.string.my_string_id); // From within your activity class.

myActivity.getString(
  R.string.my_string_id); // From other classes as instance reference.

First step : ctrl + maj + f : look for the code of the issue here = #0x7f030027

2nd step Read the name of the value, find where it is used.

3rd step If it is a PNG maybe you have not put all different sizes of it.

replace image icon from drawable-v24 to drawable, that solved my issue

I encountered the ResourceException problem when I first use BottomNavigationDrawer widget. Tyr to add all resourses for all possible dimensions, in the end, I got rid of the problem by removing all drawable-v21, and drawable-v24 folders, just leaving the conventional drawable folders.

Was facing this issue using a custom UI library, so app:srcCompt was not available. I was using latest gradle build(v3.4.1) and after downgrading to v3.2.1 the problem was fixed.

Your probably developing for newer android version from your current device. Try download SDK that is appropriate to your testing device.

You might used same resource photo twice.
this happened with me when used photo twice:
first time in main screen then used the same photo in another activity.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!