Android 4.1 Source code compilation cannot find resource file solution

Source: Internet
Author: User
Tags resource

When you modify a resource file in the Android framework, before Android 4.0, you add the corresponding resource file directly under Sourcecode/frameworks/base/core/res/res, You can then compile the framework-res, but that will change in the case of Android 4.1. In accordance with the previous method in compiling the error, the hint can not find the referenced resource file, the general situation can not find a resource file for the following reasons:

(1). The resource ID is incorrectly written, resulting in an ID mismatch;

(2). Framework-res is not compiled, resulting in the inability to find resource files; For example, if you add a picture to the framework, but you compile the framework-res before compiling the systemui that references the resource, it must not be found.

(3). Does not import the correct resource bundle; Compile the generated resource file under Frameworks/base/core/res/res save in Out/target/common/r/com/android/internal/r.java You can look in the R.java to see if you have your resource ID, and then check that the source code has no:

Import COM.ANDROID.INTERNAL.R;

(4). No modification of frameworks/base/core/res/res/values/public.xml;

4th, Android 4.1 just need to do, before Android 4.1, we add a resource file, compiled automatically added to the Public.xml, but to Android 4.1 does not, need to manually add, such as:

Added a layout file, you need to add the following code to the Public.xml:

<java-symbol type= "Layout" name= "usb_storage_connection_connected"/>

Added a string, you need to add the following code to the Public.xml:

<java-symbol type= "string" name= "Usb_storage_connection_message"/>

Added a picture, you need to add the following code to the Public.xml:

<java-symbol type= "drawable" name= "usb_storage_connected"/>

With a new ID for a control in the layout file, you need to add the following code to the Public.xml:

[HTML] View plaincopy

<java-symbol type= "id" name= "mytextview"/>

The newly added resources are modeled after public.xml in the same way.

Related Article

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.