Mastering Firebase for Android Development
上QQ阅读APP看书,第一时间看更新

SHA-1 fingerprint

Every mobile or Android developer should have an understanding of debug and release certificates for deployment. A debug certificate is for debugging purposes at the time of development, whereas a release certificate is to publish the Android application to the Play Store. These two certificates are dependent on the SHA-1 fingerprint release certificate we can create and store in known paths on the hard drive. The Android debug certificate will be stored in the .android directory and debug.keystore file. To obtain an SHA-1 fingerprint, we can make use of CLI commands or Android Studio in Windows, we shall use the following commands to get the SHA-1 fingerprint: 

  • Windowskeytool -exportcert -list -v -alias androiddebugkey -keystore %USERPROFILE%\.android\debug.keystore
  • macOS and Linux: keytool -exportcert -list –v -alias androiddebugkey -keystore ~/.android/debug.keystore

Another way is to simply use Gradle to do the hard work for us. Go to Android Studio and on the right-hand side, you will come across a Gradle option. Click on that and go to the project and select Tasks; next, choose Android and double-click on signingReport to access SHA-1 in your Gradle console. 
Actions: Android Studio | Gradle | Project | Tasks |  Android | singingReport

Variant: debugAndroidTest
Config: debug
Store: /Users/ashok/.android/debug.keystore
Alias: AndroidDebugKey
MD5: 92:AA:0A:8B:24:C8:AF:7E:B4:94:15:D2:9D:3A:1A:52
SHA1: 3C:27:01:6B:61:AD:DB:76:98:27:3F:2E:77:06:58:4C:80:60:2B:46
Valid until: Monday, 11 November, 2047

Once we obtain the SHA-1 fingerprint, we can go to the Firebase console to paste the fingerprint. Go to the project settings in Firebase console. In the section that says your apps, it will also have an option to add the SHA-1 fingerprint. Add your SHA-1 fingerprint there in the rightful place. 

The window that allows adding SHA-1 fingerprint is shown as follows:

Make sure you have enabled Google Sign-in inside the SIGN-IN METHOD tab. If you haven't enabled Google Sign-in, then you will run into exceptions that will be discussed in later sections.

The following screenshot shows enabling Google Sign-in, in the 'SIGN-IN METHOD' tab: