Android signing problem

雨燕双飞 提交于 2019-12-23 15:40:04

问题


i am trying to sign an apk by following this guide.

  1. I created a keytools folder in C:\Users\Family\workspace\ and a keys folder in the newly created keytools folder. So now i have C:\Users\Family\workspace\keytools and C:\Users\Family\workspace\keytools\keys folders.

  2. I copied the debug.keystore into the keys folder and copied the keytool.exe and jli.dll into the keytools folder.

  3. I ran cmd.exe and navigated to C:\Users\Family\workspace\keytools and ran keytool -genkey -alias anddev.keystore -keyalg RSA -validity 20000 -keystore keys/anddev.keystore

  4. The anddev.keystore file is created in the keys folder.

  5. I copied the apk to be signed into the keytools folder. I also copied jarsigner.exe into the keytools folder.

  6. In cmd.exe I am at C:\Users\Family\workspace\keytools and trying to run: jarsigner -verbose -keystore C:\Users\Family\workspace\keytools\keys\anddev.keystore -signedjar sampleapp_signed.apk sampleapp.apk anddev.keystore. It gives me this error:

    I also tried to run:

    jarsigner -verbose -keystore C:\Users\Family\workspace\keytools\keys\anddev.keystore -signedjar sampleapp_signed.apk sampleapp.apk C:\Users\Family\workspace\keytools\keys\anddev.keystore

I have also tried to run:

jarsigner -verbose -keystore C:\Users\Family\workspace\keytools\keys\anddev.keystore -signedjar C:\Users\Family\workspace\keytools\sampleapp_signed.apk C:\Users\Family\workspace\keytools\sampleapp.apk C:\Users\Family\workspace\keytools\keys\anddev.keystore

When i navigate to c:\program files\java\jdk1.6.0_23\bin and run that code it asks for the keystore password and when I write the keystore pass (123456), it gives me an error:

jarsigner: Certificate chain not found for: c:\users\family\workspace\keytools\keys\anddev.keystore. c:\users\family\workspace\keytools\keys\anddev.keystore must reference a valid Keystore key entry containing a private key and corresponding key certificate chain.

When i write anddev.keystore pass (=asdfgh, the second pass that keytool asked for at the end of the process) i get this error: jarsigner error: java.lang.RuntimeException: keystore load: Keystore was tampered with, or password was incorrect. (However, i am pretty sure this is rightful error, cause the pass is not this, but the 123456).

I am pretty sure i am getting closer and that certificate chain error is the problem. Right? Am i missing a step or what?

One another thing: in the command line when keytool asked for any password the cursor was not moving. I wrote the password but i didn't see any numbers or stars, or the cursor moving. It then asked for a reenter password, same happened. I guess this is ok, and a feature of the command line, i am just writing this to be sure.

Edit: Based on the help of Hades and Saasha, it was extremely easy to sign the apk. For anyone interested here are my steps: For this i created a MyKeys folder into C:\Users\Family\workspace. After the process the sample.keystore and the samplesigned.apk appeared in that folder.


回答1:


Hallo

If you using Eclipse you can try:

Compile and sign with Eclipse ADT

If you are using Eclipse with the ADT plugin, you can use the Export Wizard to export a signed .apk (and even create a new keystore, if necessary). The Export Wizard performs all the interaction with the Keytool and Jarsigner for you, which allows you to sign the package using a GUI instead of performing the manual procedures to compile, sign, and align, as discussed above. Once the wizard has compiled and signed your package, it will also perfom package alignment with zipalign. Because the Export Wizard uses both Keytool and Jarsigner, you should ensure that they are accessible on your computer, as described above in the Basic Setup for Signing.

To create a signed and aligned .apk in Eclipse:

  1. Select the project in the Package Explorer and select File > Export.
  2. Open the Android folder, select Export Android Application, and click Next. The Export Android Application wizard now starts, which will guide you through the process of signing your application, including steps for selecting the private key with which to sign the .apk (or creating a new keystore and private key).
  3. Complete the Export Wizard and your application will be compiled, signed, aligned, and ready for distribution.



回答2:


Don't go through all that trouble.

Are you using eclipse? If you are refer this guide.

http://developer.android.com/guide/publishing/app-signing.html

Scroll down to this heading,

"Compile and sign with Eclipse ADT"

It has a wizard for a keystore too.



来源:https://stackoverflow.com/questions/6198917/android-signing-problem

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!