No change to or addition of resources in the android framework or failure to compile

Source: Internet
Author: User

During development, especially for framework-related development, you sometimes need to re-compile the resource file. however, if you have no experience before, you may encounter problems such as failed compilation or successful compilation, no changes after pushing, or even the crazy issue of locating other resources, the following is a good article I wrote on the sharing network. I hope it will be helpful to you. The compilation sequence and precautions are as follows:

1. Resource file location: Frameworks/base/CORE/Res

2, the file generated after compilation: framework-res.apk additional COM. android. internal. R will update this R. the Directory of Java is/out/target/common/R/COM/Android/internal.

3. After compiling resources, you must re-compile framework. jar.

4. If the execution of mm in frameworks/base/CORE/RES is not re-compiled, use the toutch ### command

### Indicates a file in the directory.

5. The resource file must be in lower case.

6. If you do not need to compile resource files, you can use resources in other ways. For example, you can use ADB push to upload resources to a directory, and specify a specific directory in the program. I encountered some strange problems during resource compilation. For example, sometimes many icons will display

Error. The cause is probably related to re-compiling resources. You can try to re-compile services. jar and replace it.

 

For example, I want to use an image resource pic.png in windowmanagerservice.java. the sequence is as follows.

1. Copy pic.png to the location: Frameworks/base/CORE/RES/drawable.

2. Run touch pic.png in the frameworks/base/CORE/RES/drawable directory.

3, enter the directory frameworks/base/CORE/RES/execute mm command, compile framework-res.apk

4. After execution, Com. Android. Internal. R will generate a reference to R. drawable. PIC. You can use it in the program.

5. Execute mm compilation framework. jar in the directory frameworks/base.

6. windowmanagerservice under frameworks/base/services/Java/COM/Android/server. use COM. android. internal. r. drawable. PIC, save the file after use.

7. Go to the directory frameworks/base/services/Java/and execute mm compilation services. jar.

8. Replace the jar APK file on the machine (virtual machine or real machine.

ADB push framework-res.apk/system/framework/

ADB push services. Jar/system/framework/

ADB push framework. Jar/system/framework/

The actual path of framework-res.apk during command execution.

9. Check the Modification result on the reboot machine. It is done!

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.