Android 4.1 source code compilation cannot find the resource file solution

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.