Android APK file signature-keytool and jarsigner

Source: Internet
Author: User

1. Generate a keystore
Locate the location in the JDK binfile and enter the following name line: keytool-genkey-alias changebackgroundwid
Get. keystore-keyalg RSA-validity 20000-keystore changebackgroundwidget. keystore (do not wrap in the middle), press the "enter" key, and fill in the relevant information as prompted. The details are as follows and Figure 1 (validity is the validity period, which is 20000 days here ):
Enter the keystore password:
Enter the new password again:
What is your first name and last name?
[UNKNOWN]: mythlink
What is the name of your organization?
[UNKNOWN]: www.mythlink.com
What is your organization name?
[UNKNOWN]: www.mythlink.com
What is the name of your city or region?
[UNKNOWN]: Shen Zhen
What is the name of your state or province?
[UNKNOWN]: Guang Dong
What is the two-letter country code for this unit?
[UNKNOWN]: CN
CN = mythlink, ou = www.mythlink.com, O = www.mythlink.com, L = Shen Zhen, St = Guang Dong
Is c = cn correct?
[No]: Y
Enter the master password of <ChangeBackgroundWidget. keystore>
(If the password is the same as the keystore password, press Enter ):

Figure 1
The APK execution file signed by the handler for Android
Enter the following command line:
Jarsigner-verbose-keystore ChangeBackgroundWidget. keystore-signedjar ChangeBackgroundWidget_signed.apk ChangeBackgroundWidget.apk ChangeBackgroundWidget. keystore (no line breaks in the middle), press the "Enter" key, and Enter the key library's password phrase (that is, the password) as prompted. The details are as follows and Figure 2:
Enter the password phrase of the keystore:
Adding: META-INF/MANIFEST. MF
Adding: META-INF/CHANGEBA. SF
Adding: META-INF/CHANGEBA. RSA
Signing: Res/drawable/icon.png
Signing: Res/drawable/icon_audio.png
Signing: Res/drawable/icon_exit.png
Signing: Res/drawable/icon_folder.png
Signing: Res/drawable/icon_home.png
Signing: Res/drawable/icon_img.png
Signing: Res/drawable/icon_left.png
Signing: Res/drawable/icon_mantou.png
Signing: Res/drawable/icon_other.png
Signing: Res/drawable/icon_pause.png
Signing: Res/drawable/icon_play.png
Signing: Res/drawable/icon_return.png
Signing: Res/drawable/icon_right.png
Signing: Res/drawable/icon_set.png
Signing: Res/drawable/icon_text.png
Signing: Res/drawable/icon_xin.png
Signing: res/layout/fileitem. xml
Signing: res/layout/filelist. xml
Signing: res/layout/main. xml
Signing: res/layout/widget. xml
Signing: res/xml/widget_info.xml
Signing: AndroidManifest. xml
Signing: resources. arsc
Signing: classes. dex

Figure 2
========================================================== ======================================
In running this method, I have encountered several different problems:
Problem 1: jarsigner: Unable to open the jar file: ChangeBackgroundWidget.apk
My solution is to put the apks to be signed under the corresponding file, for example, I put the changebackgroundwidget.apk TO THE binfile of JDK.
Problem 2: jarsigner: unable to sign the jar: java.util.zip. ZipException: invalid entry comp
Ressed size (expected 1598 but got 1622 bytes)
I have not solved this problem yet. I searched the internet and found a method, but I have not fully practiced it, so I don't know if this solution is correct:
Method 1: the Android Development Network prompts that these problems are mainly caused by resource files. for android development, check the files in the res folder one by one. This problem can be solved by upgrading the JDK and JRE versions of the system.
Method 2: this is because the debug signature is implemented for the apk by default, so you cannot create a new signature. In this case, you must right-click the project and choose Android Tools> Export Unsigned Application Package.
Or from the Exporting of AndroidManifest. xml
Then, use the exported unsigned apk as the signature. During the export, it is best to select the directory where the keystore is generated before you, so that the operation is convenient.
PS: You can find a feasible solution. I hope you can tell me.
========================================================== =
Ms I found the solution to the second problem...
First, right-click the project corresponding to the APK you want to sign, select "Android Tools", right-click "Export Unsigned Application Package...", 3

Figure 3
In the displayed dialog box, store the unsigned apk in the bin folder of jdk. 4:

Figure 4
Run the preceding steps.

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.