How to Obtain SHA-1 and SHA-256 Fingerprints for Your Android App — With or Without Android Studio
How to Obtain SHA-1 and SHA-256 Fingerprints for Your Android App — With or Without Android Studio
If you're developing an Android app and need to register it with services like Firebase, Google Maps, or Facebook, you'll often be required to provide your app's SHA-1 and SHA-256 fingerprints. This blog will guide you through obtaining these fingerprints, whether you're using Android Studio or not.
📖 Table of Contents
-
What Are SHA-1 and SHA-256 Fingerprints?
-
How to Obtain SHA-1 and SHA-256 Fingerprints Using Android Studio
-
How to Obtain SHA-1 and SHA-256 Fingerprints Without Android Studio
-
Using Play App Signing to Obtain Fingerprints
-
Generating Key Hash for Services Like Facebook Login
-
FAQs
🔐 What Are SHA-1 and SHA-256 Fingerprints?
-
SHA-1: A cryptographic hash function that generates a unique fingerprint for your app's signing certificate.
-
SHA-256: A more secure and longer version of SHA-1.
These fingerprints are essential for integrating your app with services like Firebase, Google APIs, and Facebook.
🛠️ How to Obtain SHA-1 and SHA-256 Fingerprints Using Android Studio
1. Using Gradle's signingReport
Command
-
Open the Terminal tab in Android Studio.(Google for Developers)
-
Run the following command:
-
Windows:
gradlew signingReport
-
macOS/Linux:
./gradlew signingReport
-
-
The output will display the SHA-1 and SHA-256 fingerprints for your app's signing variants.(Android Developers)
2. Enabling Gradle Task List
If you don't see the signingReport
task:
-
Go to File > Settings (or Android Studio > Preferences on macOS).
-
Navigate to Build, Execution, Deployment > Compiler.
-
Uncheck Do not build Gradle task list during Gradle sync.
-
Sync your project.
-
Now, you can find
signingReport
under Gradle > Tasks > android.
🧰 How to Obtain SHA-1 and SHA-256 Fingerprints Without Android Studio
If you're not using Android Studio, you can use the keytool
utility provided with Java:
-
Open a terminal or command prompt.
-
Run the following command for your keystore:
keytool -list -v -keystore <path-to-your-keystore> -alias <your-key-alias>
Replace <path-to-your-keystore>
with the path to your keystore file and <your-key-alias>
with your key alias.
-
Enter the keystore password when prompted.
-
The output will display the SHA-1 and SHA-256 fingerprints.
🛡️ Using Play App Signing to Obtain Fingerprints
If you've opted into Play App Signing:
-
Visit the Play App Signing page.
-
Select your app.
-
Under App Signing Certificate, you'll find the SHA-1 and SHA-256 fingerprints.
These fingerprints are used for services like Firebase and Google APIs.
🔑 Generating Key Hash for Services Like Facebook Login
Some services, like Facebook Login, require a key hash:
-
Obtain your SHA-1 fingerprint using the methods above.
-
Convert the SHA-1 fingerprint to Base64:
echo <your-sha1-fingerprint> | xxd -r -p | openssl base64
Replace <your-sha1-fingerprint>
with your actual SHA-1 fingerprint.
-
Use the resulting Base64 string as your key hash.
❓ FAQs
Q1: Can I use only the debug SHA-1 for production?
No, for production, you should use the release SHA-1 fingerprint.
Q2: How do I know which SHA-1 to use?
Use the SHA-1 from your app's release keystore for production environments.
Q3: What if I lose my keystore?
If you lose your keystore, you won't be able to update your app. It's crucial to back up your keystore and its credentials.(Google Help)
Leave Message