Android: several common tips for compiling and packaging apk: android: compiling and packaging apk
Today I will share with you three tips for packaging apk with eclipse:
1. Prevent obfuscation and encryption from being decompiled:
1. Open this sentence in the project. properties file (remove "#" before this sentence)
Proguard. config =$ {sdk. dir}/tools/proguard/proguard-android.txt: proguard-project.txt
2. Then, you can define the "exception" method or class rules for the proguard-project.txt file.
For example, if the project introduces a system framework jar package, you need to add the following sentence to the file:
-Libraryjars path/framework_intermediates/classes. jar
3. When generating the apk, right-click the project name, and choose Android Tools --> Export Signed/Unsigned Application Package. Select the Save path of the apk.
It cannot be generated through Run/Launch or other methods.
In this way, when decompiling the generated apk, others will see the code that is disturbed and obfuscated to achieve difficult reading.
2. Use zipalign's 4-byte Alignment Optimization to improve apk performance:
1. In Android, when the resource file is aligned to the 4-byte boundary through memory ing, the code used to access the resource file is efficient. However, if the resource itself is not aligned (the zipalign tool is not used), it must return to the old path, read them explicitly-this process will be slow and will consume additional memory.
2. You must sign the apk file and use the following command to align it:
Zipalign-v 4 source.apk destination.apk
3. Run the following command to check whether the package is aligned:
Zipalign-c-v 4 application.apk
In the future, any apk generated by eclipse compilation and packaging should be processed by zipalign.
Zipalign file path:
Sdk directory/tools/zipalign
Idh. code/out/host/linux-x86/bin/zipalign
3. 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. The location of signapk. jar is in the source code:
Out/host/linux-x86/framework/signapk. jar
3. platform. x509.pem and platform. pk8 are both in:
Build/target/product/security/platform. pk8
4. If you do not have source code, you can use the tool I share in micro cloud: http://url.cn/LFvYbU
How can I Package Multiple APK files? Can I package more than 10 APK files into one file?
Apk APK is the abbreviation of Android Package, that is, the Android installation Package (anapk ). APK is a file format similar to Symbian Sis Or Sisx. Directly upload the APK file to the Android simulator or Android mobile phone for installation. The apk file, like sis, finally packs the android sdk-compiled project into an installer file in the apk format. The APK file is actually in zip format, but its suffix is changed to apk. After UnZip is decompressed, you can see the Dex file. Dex is the full name of Dalvik VM executes, that is, the Android Dalvik execution program, it is not a Java ME bytecode, but a Dalvik bytecode. The structure of an APK file is: META-INF \ Jar files can often see res \ directory to store resource files AndroidManifest. the global configuration file classes for the xml program. dex Dalvik bytecode resources. summary of the binary resource file compiled by arsc, we found that Android requires UnZip before running a program, and then direct like Symbian, which is different from the PE file in Windows Mobile, in this way, the confidentiality and reliability of the program are not very high. The dexdump command can be used to decompile the program. However, this method complies with the development rules. Microsoft's Windows Gadgets or WPF also adopts this architecture. In the Android platform, the dalvik vm execution file is packaged into the apk format. The loader decompress the package and then obtains the compiled androidmanifest. security Access related to the permission branch in the xml file, but there are still many security restrictions. If you upload the apk file to the/system/app folder, you will find that the execution is unrestricted. In the end, the files we usually install may not be in this folder, but the apk files in the android rom system will be placed in this folder by default, and they have the root permission.
Baidu
How to package android programs developed with eclipse into apk files?
It is automatically generated after compilation and running. You do not need to specify it.