Get key hash for release

2019-07-19 19:51发布

问题:

I have been trying to get my key hash for my release to work for hours now, and I must be doing something wrong because I have searched and tried so many different things,

Now lets say my alias is john_doe_key, and my keysotre is located at /Users/loaner/Downloads/UEat/app/app-release.apk

I would have my command in my terminal look like this correct?

keytool -exportcert -alias john_doe_key -keystore ~/Users/loaner/Downloads/UEat/app/app-release.apk | openssl sha1 -binary | openssl base64

or is that not right?

I have tried this and logging the key like face books says in the guide.

Thanks for the help in advance

回答1:

From reading your comment and seeing what you have so far, you're trying to get the key hash for Facebook, right?

First, make sure that you have signed your apk (which is your app). You can sign your apk in Android Studio by Build -> "Generate Signed APK...". When you sign your apk, you create your keystore and an alias for that keystore. I think your are confusing "keystore" with the "apk".

Also, you have to include your alias and keystore passwords in your command.

It should look like this:

keytool -exportcert -keystore keystore_file -alias alias_name -storepass keystorepassword -keypass aliaspassword | openssl sha1 -binary | openssl base64

Also, make sure that you are creating a "Release Build", which can be selected from the Build Variants menu.



回答2:

Generate a key store

$ keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000

Sign an apk.

$ jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore my_application.apk alias_name