Search code examples
google-mapsandroid-studio

How to get the SHA-1 fingerprint certificate in Android Studio for debug mode?


I am trying to make a Map app in Android Studio, on Windows. How can I find the SHA-1 fingerprint certificate number?

When I was using Eclipse it was right under Windows -> Preferences -> Android -> Build. But in Android Studio I couldn't find a similar option.

I read in the documentation that

Android Studio signs your app in debug mode automatically when you run or debug your project from the IDE.

So I tried setting my Java bin path and running the following command, taken from here:

keytool -list -v -keystore "%USERPROFILE%\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android

However, I got an error message saying that it is an illegal option.

Step by step, how do I get this information in Android Studio?

As a workaround: I previously registered my app using the SHA-1 fingerprint generated by Eclipse. Can I use the same API key to work on my project in Android Studio?


Solution

  • Easiest ways ever:

    Update added for Android Studio V 2.2 in last step

    There are two ways to do this.

    1. Faster way:

    1. Open Android Studio
    2. Open your Project
    3. Click on Gradle (From Right Side Panel, you will see Gradle Bar)
    4. Click on Refresh (Click on Refresh from Gradle Bar, you will see List Gradle scripts of your Project)
    5. Click on Your Project (Your Project Name form List (root))
    6. Click on Tasks
    7. Click on Android
    8. Double Click on signingReport (You will get SHA1 and MD5 in Run Bar(Sometimes it will be in Gradle Console))
    9. Select app module from module selection dropdown to run or debug your application

    Check the screenshot below:

    enter image description here

    2. Work with Google Maps Activity:

    1. Open Android Studio
    2. Open Your Project
    3. Click on File menu -> Select New -> Click on Google -> Select Google Maps Activity
    4. A dialog would appear -> Click on Finish
    5. Android Studio would automatically generate an XML file named with google_maps_api.xml
    6. You would get debug SHA1 key here (at line number 10 of the XML file)

    Check Screenshot below:

    Enter image description here

    Android Studio V 2.2 Update

    There is an issue with Execution.

    Solution:

    • Click on Toggle tasks execution/text mode from Run bar

    Check Screenshot below:

    enter image description here

    Done.