Android APK file signature-keytool and jarsigner

Source: Internet
Author: User

1. Generate a keystore
Locate the position in the JDK binfile and enter the following name line:

Keytool-genkey-alias changebackgroundwid get. keystore-keyalg RSA-validity 20000-eystore changebackgroundwidget. keystore

Do not wrap the line in the middle of the above command. 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
Two-letter country in the unitCodeWhat is
[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

Ii. Generate a signed APK File

Enter the changebackgroundwidget.apk file, and the final generated changebackgroundwidget_signed.apk is the APK execution file signed by Android.
Enter the following command line:

Jarsigner-verbose-keystore changebackgroundwidget. keystore-signedjar changebackgroundwidget_signed.apk changebackgroundwidget.apk changebackgroundwidget. keystore

Do not wrap the line in the middle of the above command. Press the "enter" key and enter the password phrase (that is, the password) of the keystore 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.
========================================================== =
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.

 

From: http://blog.sina.com.cn/s/blog_62c194760100gaq0.html

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.