Is the method for getting a SHA-1 fingerprint the same as the method of getting the a fingerprint? Previously, I was running this command:
First there is same .jar
file that in fb-sdk android-support-v4.jar
.
Then generate SHA1
key using:
PackageInfo info;
try {
info = getPackageManager().getPackageInfo(
"com.example.worldmission", PackageManager.GET_SIGNATURES);
for (Signature signature : info.signatures) {
MessageDigest md;
md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
String something = new String(Base64.encode(md.digest(), 0));
Log.e("Hash key", something);
System.out.println("Hash key" + something);
}
} catch (NameNotFoundException e1) {
Log.e("name not found", e1.toString());
} catch (NoSuchAlgorithmException e) {
Log.e("no such an algorithm", e.toString());
} catch (Exception e) {
Log.e("exception", e.toString());
}
In Addition to Lokesh Tiwar's answer
For release builds add the following in the gradle:
android {
defaultConfig{
//Goes here
}
signingConfigs {
release {
storeFile file("PATH TO THE KEY_STORE FILE")
storePassword "PASSWORD"
keyAlias "ALIAS_NAME"
keyPassword "KEY_PASSWORD"
}
}
buildTypes {
release {
zipAlignEnabled true
minifyEnabled false
signingConfig signingConfigs.release
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
Now running the signingReport as in Lokesh's Answer would show the SHA 1 and MD5 keys for the release builds as well.
from a Debug Keystore we can get the SHA1 value in Eclipse
. Accessing from the menu:
Window
-> Preferences
-> Android
-> Build
but it doesn´t work for a production Keystore
.
So, to get the SHA1 value from a production Keystore go to:
Android Tools
-> Export Signed Application Package
. Follow the process for signing your apk and the SHA1 will showed as a certificate.
if you have not the Keystore and alias you can use this command :
keytool -list -printcert -jarfile app.apk
Go to your java bin directory via the cmd:
C:\Program Files\Java\jdk1.7.0_25\bin>
Now type in the below comand in your cmd:
keytool -list -v -keystore "c:\users\your_user_name\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android
If you are using Android Studio IDE then you can get SHA1 has value for your all build variants with one click.
Under Gradle Projects Window > Select Root Project > signingReport > double click
Next
Go To Variant: release for release
Go To Variant: debug for debug
http://devdeeds.com/create-sha1-key-using-android-studio/