Application of Android Development package signature obfuscation process

Source: Internet
Author: User

the project was done almost, to sign, and then the obfuscation was reversed, documenting the processThe default environments are all configured.
The main points are the following steps1. Build the configuration files required for ant packaging2. Create an application signature KeyStore, and sign the APK3. Write confusing files, confuse code, prevent decompile
The first step is to build the ant packaged configuration file Execute the instructions under the project root:android Update Project -path. three directories are automatically generated: build.xml,local.properties,proguard-project.txt and a ant.properties to build on her own.
A total of four file build.xml:Ant default makefile, describes the packaged tasks and processes, its syntax reference click Open link
local.properties: Contains local environment variablessdk.dir=/users/ xx /eclipse/ADT-bundle-mac-x86_64-20131030/SDK
Proguard-project.txt: Confusing files, confusing code, syntax reference click to open link
ant.properties: The associated configuration of the signature file.
This can be done using ant to package the application, go to the application root directory, run ant release, will be in the bin directory to generate a packaged apk, but it is not signed, this time has not been configured.
Step two, generate KeyStore, configure signaturecommand: Keytool-genkey-keystore jason0539.keystore-keyalg rsa-validity 10000-alias jason0539.keystoreEnter KeyStore password: *********Enter the new password again:
What is your first and last name?
[Unknown]: blog.csdn.net/jason0539
What is the name of your organizational unit?
[Unknown]: jason0539
What is your organization's name?
[Unknown]: jason0539
What is the name of your city or region?
[Unknown]: Qinhuangdao
What is the name of your state/province?
[Unknown]: Hebei
What is the two-letter country/region code for this unit?[Unknown]: CNcn=huodianditu.bmob.cn, ou=jason0539, o=jason0539, l= Qinhuangdao, st= Hebei, C=CN correct?
[No]: y
Enter the key password for <jason0539.keysotre>(if the keystore password is the same, press ENTER):The Jason0539.keystore file is generated in the directory after the carriage return, which is the file used to sign the application.

Command parameter Description:

-genkey Generate certificate file-keystore in the. keystore file for the specified KeyStore-keyalg The algorithm that specifies the key-validity is a valid number of days for a certificate, and here we write for 10,000 days. -alias Generating aliases
When you enter the password does not echo, just enter it, the general number of recommended 20-bit, do not need to write down the back of the use, Note:

1, CN (Common name-first and last name): In fact, this "name and surname" should be a domain name, such as localhost or blog.devep.net. Lose the name, and really run the time when the domain name does not match, will be problematic. When the browser accesses, a dialog box appears, prompting "the name on the security certificate is invalid or does not match the site name" and the user chooses to continue or browse the Web page. However, an exception similar to "Javax.servlet.ServletException:HTTPS hostname wrong:should be" is thrown when the HTTP client writes a program access.


2. When generating a digital certificate with Keytool, you must ensure that the name-keystore Androidapp.keystore-alias Androidapp.keystore must be the same. Otherwise, the next signature will appear with an error: Jarsigner: Unable to find the Androidapp.keystore certificate chain. Androidapp.keystore must reference a valid KeyStore key entry that contains the private key and the corresponding public key certificate chain.
Third step, next configure Ant.properties, use KeyStore to sign apkin the Ant.properties file, add the following:key.store=jason0539.keystore key.alias=jason0539.keystore key.store.password=***key.alias.password=***android.library=false
among them:KeyStore is the private key library file. key is the private key to be used for signing. Key.store.password is the password for the private key library. Key.alias.password is the password for the private key.
This step is completed, and then the command line runs directly ant release will be packaged successfully and is signed in the Bin directory.
This step encountered the problem: the first time the alias of the KeyStore into the Keystroe, the result has been prompted build.xml:1151:signing key Jason0539.keystore not found later to delete this, To regenerate a new Keystore, the results suggest that Android Keystore was tampered with, or password was Incorrect:password Verification later realized that it may be related to the name of two KeyStore, and then delete, regenerate A, the name is not called Jason0539.keystore, changed to Jason.keystore, this success.
Fourth step, confusing files

In Project.Properties, there is a line of commented out code as follows

Proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

Cancel this line of comments, and then, according to your own project, to write proguard-project.txt this file to be confused. Specific confusion syntax can refer to click to open the link this step is mainly to note that if the project with a third-party jar package, such as Baidu Map, to keep in mind that some of the class is not confused, otherwise it will crash, specifically to keep what class, in the Baidu open platform will have a description, go to the official website of the jar package to see just If you use a lot of third-party SDK, the confusion may start the application will be crash, it is recommended to find the corresponding problem based on log SDK, and then go to the open platform to see the confusion considerations, the need to keep the class protection good. And so on, it's OK to configure all third-party SDKs.
More references via ant script, compiling and packaging Android project
Android Proguard Detailed
Ant Use full summary


jason0539

Blog: http://blog.csdn.net/jason0539 (reprint please indicate the source)

Sweep the code to pay attention to the public number, something different


Android Development Application Packaging signature obfuscation process

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.