How to get the SHA-1 fingerprint certificate in An

2018-12-31 05:31发布

I have shifted myself from Eclipse to Android Studio. Now I am trying to work on my Map app. So I need my 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 out any option like this so that I could find easily the fingerprint. I am using Windows. I have read from this link that:

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

So I tried to run this in command line after setting my Java bin path from this link and unfortunately couldn't find my fingerprint. It is saying that it is an illegal option.

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

Is there a way to find the SHA-1 fingerprint from Android Studio like it was very easy in Eclipse? As I am newbie in Android Studio, what is the full process to find it?

Another thing I want to add is that I have my Eclipse generates the SHA-1 fingerprint and previously I have my app registered on that fingerprint in Google developer console, and I worked on that app in Eclipse by that API key. Is the same API key can be worked on this my project in Android Studio?

30条回答
后来的你喜欢了谁
2楼-- · 2018-12-31 05:35

If you are using Android Studio, you can get the SHA-1 and MD5 certificate fingerprint (debug, release... all Build Types!!) fast through Gradle Tasks:

signingReport

The SHA-1 and MD5 certificates are shown in Messages Logs.

Android Plugin (configured in the Gradle app) creates a debug mode for default.

com.android.application

File route to keystore:

HOME/.android/debug.keystore

I recommend to attach debug.keystore to build.gradle. To do this put a file, debug.keystore, in an app folder and then Add SigningConfigs in Gradle app:

apply plugin: 'com.android.application'

    android {
        ................
        signingConfigs {
            debug {
                storeFile file("../app/debug.keystore")
                storePassword "android"
                keyAlias "androiddebugkey"
                keyPassword "android"
            }
            release {
                storeFile file("../app/debug.keystore")
                storePassword "android"
                keyAlias "androiddebugkey"
                keyPassword "android"
            }
        }
        ........
    }

Extra: If you want creates for release, put a file, release.keystore, in an app folder. (This example uses the same debug.keystore.)

查看更多
只靠听说
3楼-- · 2018-12-31 05:36

The easiest way to get the finger print is to switch from app to signed report by clicking the drop down and click build.

enter image description here

Then you will be able to see the sha1 fingerprint at the bottom pane where you see the debug report and stack trace. N.B remember to switch back to app when you want to run your app on a device or an emulator.

查看更多
皆成旧梦
4楼-- · 2018-12-31 05:37

I just found the case to get SHA-1 in Android Studio:

  1. Click on your package and choose New -> Google -> Google Maps Activity
  2. Android Studio redirects you to google_maps_api.xml

And you will see all you need to get google_maps_key.

Image

查看更多
爱死公子算了
5楼-- · 2018-12-31 05:37

For Mac, this worked perfectly:

keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
查看更多
时光乱了年华
6楼-- · 2018-12-31 05:37

This worked in my case: Use %USERPROFILE% instead of giving path .keystore file stored in this path automatically C:Users/user name/.android:

keytool -list -v -keystore "%USERPROFILE%\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android
查看更多
看风景的人
7楼-- · 2018-12-31 05:37

I found a very easy process to find you MD5, SHA-1 fingerprint using Android Studio.

  1. Run your project
  2. Go to Gradle Menu (Menu: View -> Tool Windows -> Gradle)
  3. Go to 'signingReport' in Gradle window. (Your project -> Tasks -> android -> signingReport)
  4. Run it. (Using double-click or Ctrl + Shift + F10)
  5. In Run window you will find all info.

It's work only for debug mode. In realease mode I can not see sha-1. Here result of gradlew signingReport

Variant: release
Config: none
----------
Variant: releaseUnitTest
Config: none
----------
Variant: debug
Config: debug
Store: path\Android\avd\.android\debug.keystore
Alias: AndroidDebugKey
MD5: xx:xx:xx:62:86:B7:9C:BC:FB:AD:C8:C6:64:69:xx:xx
SHA1: xx:xx:xx:xx:0F:B0:82:86:1D:14:0D:AF:67:99:58:1A:01:xx:xx:xx
Valid until: Friday, July 19, 2047
----------

So I must use keytool to get sha-1. Here official Firebase doc:

Get_sha-1_for_release

查看更多
登录 后发表回答