Resources can be packaged in various ways from raw materials, optimized for packed byte data. All stuck in one apk. Resource Id helps to find it. During development, the aapt constantly scans the res directory for xml, images, etc. And generates numerical constants in R.java . Read more about the Android build process .
At run time, the Resources instance decides where to look, depending on whether its get method is called. The numerical value of Id helps to request a resource mapping and find the right one. Actual data loading is handled by its own low-level code.
The debugger can display objects and their fields. To find out what is missing, read the NotFoundException error NotFoundException in logcat. It indicates the hexadecimal value of the resource identifier.
ApkTool allows you to deflate the apk file and rebuild the res directory.
Update:
How resources are packaged:
If you have apk and want to see the full resource table, run the aapt tool in the SDK as:
aapt list -v myApp.apk
It will display the details as:
Archive: ./myApp.apk Length Method Size Ratio Offset Date Time CRC-32 Name -------- ------ ------- ----- ------- ---- ---- ------ ---- 468 Deflate 228 51% 0 11-07-12 23:25 29fb0660 res/color/abs__primary_text_disable_only_holo_dark.xml 468 Deflate 228 51% 332 11-07-12 23:25 bae4791a res/color/abs__primary_text_disable_only_holo_light.xml 2942 Stored 2942 0% 280417 10-27-12 16:52 9b5af43b res/drawable-xhdpi/ic_mus.png 2330 Stored 2330 0% 283418 10-27-12 16:52 21f5ba4d res/drawable-xhdpi/ic_pic.png 1556 Stored 1556 0% 285810 10-27-12 16:52 31c3402b res/drawable-xhdpi/ic_vid.png
You will see a method (deflate, stored, etc.) and an offset in the binary data where the resource is stored, and a length that indicates the number of bytes that will be read after the offset to get this resource.
What a Resources.NotFoundException :
Here is the code that generates it:
public void getValue(int id, TypedValue outValue, boolean resolveRefs) throws NotFoundException { boolean found = mAssets.getResourceValue(id, 0, outValue, resolveRefs); if (found) { return; } throw new NotFoundException("Resource ID #0x" + Integer.toHexString(id)); }
Thus, it prints the hexadecimal Id value for which the Resources instance is requested.
Here is the part of R.java :
public static int absForceOverflow=0x7f010039;
You can see that Id gets similar Hex values.
Can I solve this error?
The error should not occur in the first place if the build tools compiled by you are completed successfully. There you can do nothing but clean up or restore the project. This is an error in the build tools or resource loader OR data corruption in the apk on the device.