When modifying resource files in the Android framework, before Android 4.0, the corresponding resource files are directly added under sourcecode/frameworks/base/core/res, then compile the framework-res, but this situation changes in Android 4.1. According to the previous method, an error is reported during compilation, prompting that the referenced resource file cannot be found. Generally, the following causes cannot be found:
(1) The resource id is wrong, resulting in id mismatch;
(2 ). if framework-res is not compiled, the resource file cannot be found. For example, you add an image to the framework, but you compile the SystemUI that references the resource before compiling framework-res, it must not be found.
(3 ). the correct resource package is not imported; the resource files compiled under frameworks/base/core/res are stored in out/target/common/R/com/android/internal/R. java can be used in the R. check whether your resource id is in java, and then check whether the source code is:
Import com. android. internal. R;
(4). frameworks/base/core/res/values/public. xml is not modified;
The fourth point is Android 4.1. Before Android 4.1, we add a resource file which will be automatically added to public during compilation. in xml, but not in Android 4.1, You need to manually add, such:
If a layout file is added, add the following code to public. xml:
<Java-symbol type = "layout" name = "usb_storage_connection_connected"/>
If a string is added, add the following code to public. xml:
<Java-symbol type = "string" name = "usb_storage_connection_message"/>
Add the following code to public. xml:
<Java-symbol type = "drawable" name = "usb_storage_connected"/>
Add a Control id in the layout file, and add the following code in public. xml:
[Html] view plaincopy
<Java-symbol type = "id" name = "mytextView"/>
Add the newly added resource in the same way as public. xml.