问题
I've used phonegap Build to create my .apk file and i'm trying to sign it.
I understand that I can do this with the following command:
$ keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -validity 10000
But when I run this in terminal I get 'command not found' ?
I'm running this on a mac so from what I've read I have the required JDK installed ( I have xcode ) I guess it might be that the PATH is not set correctly to keytool, but I'm unable to find any simple info on resetting this.
Any help would be hugely appreciated. I must be missing something very simple as it can not be this difficult to sign the app ?!?!
回答1:
Make sure you have cd
'd into the android-sdk/platform-tools directory (where the keytool will [most likely] reside). The command won't be found if you aren't in the keytool-containing directory.
回答2:
This was a nightmare for me, such a seemingly simple task took far too long.
to locate Keytool on a mac
first type this into command prompt:
/usr/libexec/java_home -v 1.7
it will spit out something like:
/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home
keytool is located in the same directory as javac
. ie:
/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/bin
From bin directory you can use the keytool.
I usually use the APK
tools in Eclipse
to sign keys but I generated the fingerprint in past and didn't record it. I need keytool to tell me that value...
Hopefully that helps someone else
回答3:
keytool
comes with the Java Development Kit (JDK). So look for the directory that contains javac, java and you will find keytool present over there. You can run it directly from that directory or set the PATH.
回答4:
Just a note i had to add './'
in front within the keytool location.
Keytool Location
/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/keytool
Command run
./keytool -genkey -v -keystore ~/key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias key
Hope that helps someone.
回答5:
I had this same error when running on Mac.
Removing the '$' worked for me, and was then prompted to enter the details to create the keystore.
I then had trouble finding the keystore, as I thought it would be within .android under my user account, but it was actually saved straight to my user account [cd users/YourUserName]
Hope that helps anyone with the same issue
来源:https://stackoverflow.com/questions/11850556/not-able-to-locate-keytool-on-my-mac-to-sign-my-apk-file