Android Studio uses a debug keystore to sign applications during development. To use certain features like Google Maps, you need to obtain the SHA-1 fingerprint certificate from this keystore. Here’s how you can do it:
Method 1: Using the Gradle Signing Report
- Open your project in Android Studio.
- Click on the Gradle button on the right side of the IDE to open the Gradle panel.
- In the Gradle panel, click on the Refresh button to refresh the list of tasks.
- Expand the app module and navigate to Tasks > Android.
- Double-click on signingReport to generate the signing report.
The SHA-1 fingerprint certificate will be displayed in the Run console or the Gradle Console.
Method 2: Using the Google Maps Activity
- Open your project in Android Studio.
- Click on File > New > Google > Google Maps Activity to create a new Google Maps activity.
- Follow the prompts to create the activity.
- Android Studio will generate an
google_maps_api.xml
file containing the SHA-1 fingerprint certificate.
You can find the SHA-1 fingerprint certificate in this XML file, usually on line 10.
Method 3: Using the Keytool Command
If you prefer to use the command line, you can obtain the SHA-1 fingerprint certificate using the keytool
command:
keytool -list -v -keystore "%USERPROFILE%\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android
On Mac or Linux, use:
keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
Make sure to navigate to the Java bin
directory before running this command.
Tips and Variations
- If you’re using Android Studio 4.2 or later, you may need to use the Execute Gradle Task terminal instead of the Run console.
- To obtain the SHA-1 fingerprint certificate for a Flutter or React Native project, navigate to the
android
folder and run thegradlew signingreport
command. - If you’ve previously registered your app with a different SHA-1 fingerprint certificate (e.g., from Eclipse), you can use the same API key in Android Studio.
By following these methods, you should be able to obtain the SHA-1 fingerprint certificate for your Android project in Android Studio.