First, Generate KeyStore
Locate the location in the JDK bin file and enter the following named line:
Keytool-genkey-alias Changebackgroundwid get.keystore-keyalg rsa-validity 20000-keystore Changebackgroundwidget.keystore
The above command does not break the line, press "Enter" key, and according to the prompt to fill in the relevant information, details as follows and Figure 1 (validity is valid, here is valid for 20,000 days):
Enter KeyStore Password:
Enter the new password again:
What is your first and last name?
[Unknown]: Mythlink
What is the name of your organizational unit?
[Unknown]: www.mythlink.com
What is your organization's 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
, C=CN correct?
[No]: Y
Enter the master password for <ChangeBackgroundWidget.keystore>
(If the KeyStore password is the same, press ENTER):
Figure 1
Two, can generate the signature apk file
Enter file changebackgroundwidget.apk here, eventually generate changebackgroundwidget_signed.apk for Android signed apk execution file
Enter the following command line:
Jarsigner-verbose-keystore Changebackgroundwidget.keystore-signedjar changebackgroundwidget_signed.apk changebackgroundwidget.apk Changebackgroundwidget.keystore
The above command does not break the line, press "enter" key, according to the prompt to enter the key store password phrase (that is, password), the details are as follows and Figure 2:
Enter the password phrase for 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 way, I have encountered several different problems:
Problem One: Jarsigner: Unable to open jar file: changebackgroundwidget.apk
My workaround is to put the APK that will be signed into the corresponding file, such as I put the signed changebackgroundwidget.apk in the JDK bin file.
Issue two: Jarsigner: Unable to sign jar: Java.util.zip.ZipException:invalid entry Comp
Ressed size (expected 1598 but got 1622 bytes)
This problem, I have not solved, search on the Internet, found a method, but I do not complete, so do not know whether this solution is correct:
Method One: The Android development network prompted these problems mainly due to resource files, for Android development should check the Res folder files, one by one. This problem can be resolved by upgrading the JDK and JRE versions of the system.
Method Two: This is because the default to the APK to do the debug signature, so unable to make a new signature then must point the project right->android Tools->export Unsigned application package.
or from Androidmanifest.xml's exporting.
And then based on this exported unsigned apk to do the signature, the best time to export its directory in the KeyStore you created before the directory, so it is convenient to operate.
==========================================
Ms I found a solution to the second problem ...
First right click on the item you want to sign the APK for, select "Export Unsigned application Package ..." in the "Android Tools" right extension bar,, 3
Figure 3
In the pop-up dialog box, save this unsigned apk in the JDK Bin folder, 4:
Figure 4
Then you can run the above steps.
Android apk file Signature--keytool and Jarsigner