15

In Windows command prompt:

>keytool -genkey -alias me
>keytool -selfcert -alias me
>jarsigner myJar.jar me
Only one alias can be specified

I have failed to find any info on this error on the web. I'm obviously only specifying one alias here. What could I be doing wrong?

unmuse
  • 677
  • 2
  • 9
  • 21
  • It seems that the error is displayed if there are other parameters not starting with dash that the jar and alias: http://webcache.googleusercontent.com/search?q=cache:WriOTi-nGrUJ:www.docjar.com/docs/api/sun/security/tools/JarSigner.html+&cd=8&hl=fi&ct=clnk&gl=fi&client=firefox-a Your input seems correct. – Juuso Ohtonen Mar 09 '12 at 10:58

4 Answers4

29

I was getting the same error.

I resolved it by renaming the folders in my path

c:\this is a folder\ replaced with c:\this_is_a_folder\

jarsigner doesn't like spaces in folders

Joel Davis
  • 522
  • 5
  • 14
  • I never use spaces in any workspace directory. Still get the problem. – Martin Apr 07 '15 at 08:25
  • Need more information to solve this, what is the command you are using? This particular problem was related to something similar to `C:\Program Files (x86)\Java\jdk1.7.0_40\bin>jarsigner.exe -verbose -storetype pkcs12 -keystore e:\mk_ca.pfx -tsa http://timestamp.globalsign.com/scripts/timestamp.dll -storepass password "E:\wamp\www\app\test.jar" "keyblahblahblah123"` – Joel Davis Apr 09 '15 at 00:03
  • 2
    jarsigner never even sees the spaces in folders. It is the *command shell* that doesn't understand them. You need to quote arguments with spaces in them, to *any* program. Nothing to do with jarsigner whatsoever. – user207421 Aug 25 '15 at 23:16
4

Just put quotes around the filename(s) with spaces. You need to quote arguments with spaces in them, to any program. Nothing to do with jarsigner whatsoever.

user207421
  • 305,947
  • 44
  • 307
  • 483
3

Remove the space from Folder Name like

jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.jks D:\AndroidProject\CheckFinalCodeNew\CheckFinalCode\platforms\android\build\outputs\apk\android-release-unsigned.apk my-alias

The problem would be resolve

Sumant Singh
  • 904
  • 1
  • 14
  • 16
-2

I had the same problem and solved it by switching to jarsigner from jdk 6. Although I created my cert with keytool from jdk 7, I could not sign it with its jarsigner.

alestanis
  • 21,519
  • 4
  • 48
  • 67
jan
  • 2,741
  • 4
  • 35
  • 56
  • Who is downvoting my answer and why? Check other comments to see there are other users that had this issue without space related folder names etc. This was a working solution for me at this time. – jan Nov 09 '18 at 12:34