How to Get SHA1 Key and SHA 256 Key for Your Flutter Project in Vscode
Hello everyone! Today, I'm going to show you how to obtain the SHA1 key or SSC 256 key for your Android project. These keys are important for various purposes, such as authentication and security. Let's get started!
To begin, you need to navigate to the root level of your project, which is located inside the Android folder. Once you're there, open your terminal or command prompt and type the following command:
bash./gradlew signin
Now, if you still receive an error similar to the one I faced, which says "gradlew is not recognized as an internal or external command," you may need to change the Java home environment variable. Follow the steps below to resolve this issue:
Attempt to update your Java installation from the Java Configuration application. However, if this doesn't work, proceed to the next step.
Delete all Java files from your system and perform a clean installation of Java. Here's how you can do it:
Go to your local disk (usually C:) and navigate to the "Program Files" directory.
Delete the "Java" folder. If you come across an "Oracle" folder inside the "Common Files" directory, delete that as well. Note that I have already deleted it, so it may not appear for me.
Similarly, delete the "Java" folder inside the "Program Files" directory, as shown below:
Finally, delete the "Oracle" folder within the "Common Files" directory, which contains Java.
Great! You have successfully removed the older version of Java. Now, let's proceed with installing the latest JDK (Java Development Kit). Follow the steps below:
- Open Chrome and search for the latest JDK version download.
- Visit oracle.com and download the 64-bit Windows installer for JDK.
- Once the download is complete, execute the installer.
- The installer will automatically install the latest version of JDK inside the "Program Files" directory on your local disk. You can find the "Java" folder there.
- Make note of the installation location. Inside the "Java" folder, you will see the latest version of JDK installed. Copy the location for the next step.
Now, let's add the JDK location to the environment variable:
- Go to your system's environment variables.
- Under the "System Variables" section, click on "New".
- Enter the variable name as
JAVA_HOME
. - Paste the value you copied earlier, which is the installation location of your latest JDK version.
Next, let's ensure that the Java path is correctly set:
- Locate the "Path" variable within the system variables and click on "Edit".
- By default, the installer should have already added the proper location of the Oracle Java path. However, if it hasn't, you need to add it manually.
- Click on "New" and add the Java path. If you notice duplicate entries, remove the extra one to avoid conflicts.
Make sure to save all the changes you've made to the environment variables.
Finally, navigate back to the root level of your project within the Android directory using the terminal or command prompt. Execute the following command to obtain all the necessary information, including the SSC 256 key, SHA1 key, MD5 hash, and more:
bash./gradlew signinreport
Congratulations! You have successfully retrieved the required keys and information for your Android project.
That's it for this tutorial! I hope you found it helpful. If you have any questions or encounter any issues, feel free to leave a comment below.
Happy coding!