Android Tutorial

Software Setup and Configuration

Android Studio

File Structure

Components

Core Topics

Layout

View

Button

Intent and Intent Filters

Toast

RecyclerView

Fragments

Adapters

Other UI Component

Image Loading Libraries

Date and Time

Material Design

Bars

Working with Google Maps

Chart

Animation

Database

Advance Android

Jetpack

Architecture

App Publish

App Monetization

How to Generate SHA1, MD5, and SHA-256 Keys in Android Studio?

To generate SHA-1, MD5, and SHA-256 keys (or fingerprints) for your Android application in Android Studio, you'll typically use the keytool utility that comes with the JDK. These fingerprints are often needed for API services, like Google Maps or Firebase, to identify your app.

Follow these steps to generate the keys:

  1. Open Terminal in Android Studio:

    • On the bottom of Android Studio, you'll find a tab called "Terminal". Click on it to open the terminal. Alternatively, you can use your computer's command prompt or terminal.
  2. Navigate to the Java Bin Directory (optional):

    If keytool isn't recognized as a command directly (common in Windows), you might need to navigate to the bin directory of your JDK installation. For example:

    cd C:\Program Files\Java\jdk1.8.0_231\bin
    

    Adjust the path based on your JDK installation directory.

  3. Generate the Key Fingerprints:

    Use the following command:

    keytool -list -v -keystore path_to_your_keystore.jks
    

    Replace path_to_your_keystore.jks with the path to your keystore file. If you're trying to get the fingerprint for your debug keystore, the path usually is:

    • For Windows:

      C:\Users\Your_Username\.android\debug.keystore
      
    • For macOS or Linux:

      ~/.android/debug.keystore
      

    If you're using the debug keystore, the default keystore password is android.

  4. View the Keys:

    After running the command, you will be prompted to enter the keystore password. Once you provide the password, you'll see output that includes SHA-1, MD5, and SHA-256 fingerprints, among other details.

Remember:

  • Always keep your release keystore file and password secure. Losing the keystore means you won't be able to update your app on the Google Play Store. Exposing it can lead to malicious versions of your app being distributed.

  • If you're integrating a service like Google Maps or Firebase, you may need the SHA-1 fingerprint from both your debug and release keystores, especially if you're testing functionality in both debug and release modes.

  1. Generate SHA-1 key in Android Studio:

    • Open the terminal in Android Studio and run the following command:
    keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
    
  2. How to get MD5 key in Android Studio for Google Maps:

    • Run the following command in the terminal:
    keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
    
  3. Android Studio generate SHA-256 key for Firebase:

    • Run the following command in the terminal:
    keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
    
  4. Create SHA-1 fingerprint in Android Studio:

    • Use the following command in the terminal:
    keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
    
  5. Generate MD5 key for debug keystore in Android Studio:

    • Run the following command in the terminal:
    keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
    
  6. Get SHA-256 fingerprint for Firebase in Android Studio:

    • Run the following command in the terminal:
    keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
    
  7. Android Studio generate keystore SHA-1 and SHA-256:

    • Use the following command to generate a new keystore and obtain SHA-1 and SHA-256 fingerprints:
    keytool -genkeypair -v -keystore your_keystore_filename.keystore -keyalg RSA -keysize 2048 -validity 10000 -alias your_alias_name
    

    Replace "your_keystore_filename" and "your_alias_name" with your desired values.

  8. Obtain MD5 key for signing APK in Android Studio:

    • Run the following command in the terminal:
    keytool -list -v -keystore your_keystore_filename.keystore -alias your_alias_name
    

    Replace "your_keystore_filename" and "your_alias_name" with your actual keystore filename and alias.

  9. Generate SHA-256 key for Google Play Console in Android:

    • Run the following command in the terminal:
    keytool -list -v -keystore your_keystore_filename.keystore -alias your_alias_name
    

    Replace "your_keystore_filename" and "your_alias_name" with your actual keystore filename and alias.