Android compilation Pack apk when a few common tips

Source: Internet
Author: User

Share with you today three tips for packaging your apk with eclipse:

One. Prevent decompile and confuse encryption:

1. Please open this sentence in the Project.Properties file (the "#" in front of this sentence will be removed)
Proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

2. You can then make an "exception" to the Proguard-project.txt file or the rule definition of the class according to your own needs
For example, if the project introduces a jar package for a system's framework, you need to add the following sentence to this file:
-libraryjars Path/framework_intermediates/classes.jar

3. When the APK is generated, right-click the project name, Android Tools---Export signed/unsigned application package. Select the save path of the APK.
It is impossible to achieve the goal by means of run/launch.

The resulting apk, the other people in the anti-compilation, see is disturbed by confusion to achieve the purpose of reading difficult code.


Two. Use the Zipalign 4-byte alignment optimization to improve the APK performance:

1. In Android, the code that accesses a resource file is efficient when the resource file is aligned to a 4-byte boundary through memory mapping. However, if the resource itself is not aligned (without using the Zipalign tool), it must go back to the old path and explicitly read them-the process will be slow and will cost extra memory.

2. You must do so after signing the APK file, using the following command to align it:
Zipalign-v 4 source.apk destination.apk

3. The following commands are used to check whether the package is aligned:
Zipalign-c-V 4 application.apk

After all, the eclipse compiled package generated apk, it is best to go through zipalign processing.

Zipalign file path:
SDK Directory/tools/zipalign
Idh.code/out/host/linux-x86/bin/zipalign


Three. Re-sign the packaged APK:

1. Change the APK signature command:
Java-jar Signapk.jar Platform.x509.pem platform.pk8 test.apk test_signed.apk

Note
2. Signapk.jar location in source code:
Out/host/linux-x86/framework/signapk.jar

3.platform.x509.pem and Platform.pk8 are in:
Build/target/product/security/platform.pk8

4. If no source of friends can use I share in the micro-cloud tools:Http://url.cn/LFvYbU


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.