Reputation: 687
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?
Upvotes: 15
Views: 18097
Reputation: 176
For me, it was the whitespaces that caused the same error.
My previous CLI command was
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore ${KEYSTORE_FILE} ${UNSIGNED_APK} key0
Then I wrapped my variables with double quotes which solved my problem
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore "${KEYSTORE_FILE}" "${UNSIGNED_APK}" key0
Upvotes: 0
Reputation: 2873
I was getting this error even though I had put quotes around my paths, and also when I moved everything to a folder name with no spaces at. The spaces in the path turned out to be a Red Herring.
Confusingly, Jarsigner would work from a Command Prompt window, but not from Powershell, the Windows Terminal app, or an Ant Task (using an exec
job).
Turns out I'd copied and pasted the basic Jarsigner command from a PDF, and one of the hyphens in the command wasn't a real hyphen, but some Unicode doppelganger.
(I probably ought to let @mark-rabjohn write this up and get the credit, as it was his brainwave to check it was all ASCII, but as this wasted six hours of my life I'm just not feeling that generous.)
Upvotes: 0
Reputation: 1020
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
Upvotes: 3
Reputation: 310893
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.
Upvotes: 4
Reputation: 2830
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.
Upvotes: -2
Reputation: 552
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
Upvotes: 29