如何在Android Studio中获取SHA-1指纹证书以获得调试模式?

本文翻译自:How to get the SHA-1 fingerprint certificate in Android Studio for debug mode?

I have shifted myself from Eclipse to Android Studio . 我已将自己从Eclipse转移到Android Studio Now I am trying to work on my Map app. 现在我正在尝试使用我的地图应用程序。 So I need my SHA-1 fingerprint certificate number. 所以我需要我的SHA-1指纹证书号码。

When I was using Eclipse it was right under Windows -> Preferences -> Android -> Build . 当我使用Eclipse时,它正好在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. 但是在Android Studio中,我找不到这样的选项,以便我可以轻松找到指纹。 I am using Windows. 我正在使用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. 当您从IDE运行或调试项目时,Android Studio会自动在调试模式下签署您的应用程序。

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. 所以我尝试在从此链接设置我的Java bin路径后在命令行中运行它,但遗憾的是找不到我的指纹。 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? 有没有办法从Android Studio中找到SHA-1指纹,就像在Eclipse中一样容易? As I am newbie in Android Studio, what is the full process to find it? 由于我是Android Studio中的新手,找到它的完整过程是什么?

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. 我想要添加的另一件事是我的Eclipse生成了SHA-1指纹,之前我在Google开发人员控制台中将该应用程序注册在该指纹上,并且我通过该API密钥在Eclipse中使用该应用程序。 Is the same API key can be worked on this my project in Android Studio? 在Android Studio中我的项目是否可以使用相同的API密钥?


#1楼

参考:https://stackoom.com/question/1rqTa/如何在Android-Studio中获取SHA-指纹证书以获得调试模式


#2楼

  • Go to File > Project Structure Select app or mobile whatever you gave the name from Modules 转到文件>项目结构选择appmobile无论您从Modules提供名称

  • Choose Signing tab. 选择Signing选项卡。

  • You can add certificate clicking on the + button. 您可以在+按钮上添加证书。


#3楼

My problem is the same as I have also shifted my Google Maps project from Eclipse to Android Studio . 我的问题与我将谷歌地图项目从Eclipse转移到Android Studio一样 I have solved my problem by following this: 我通过以下方式解决了我的问题:

Go to your Java bin directory via the command: 通过以下命令转到Java bin目录:

C:\Program Files\Java\jdk1.7.0_71\bin>

Now type in the below command in your command window (CMD.EXE): 现在在命令窗口(CMD.EXE)中键入以下命令:

keytool -list -v -keystore c:\users\your_user_name\.android\debug.keystore -alias androiddebugkey -storepass android -keypass android

Example: 例:

keytool -list -v -keystore c:\users\James\.android\debug.keystore -alias androiddebugkey -storepass android -keypass android

Or you can just write this in cmd if you don't know the username: 或者如果你不知道用户名,你可以在cmd中写这个:

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

And you will get the SHA1. 你会得到SHA1。

Then I created a new key from https://code.google.com/apis/console because of my package name got changed and then use this key in my application. 然后我从https://code.google.com/apis/console创建了一个新密钥,因为我的软件包名称已更改,然后在我的应用程序中使用此密钥。 It works fine. 它工作正常。

Make sure you are in BIN folder of jdkX.X.X_XX (my folder name is jdk1.7.0_71) , or else if you don't know what folder name you have then find it by opening the Java folder, and you will see what the folder name is, but you must be in your BIN folder and then run this command. 确保你在jdkX.X.X_XX的 BIN文件夹中(我的文件夹名称是jdk1.7.0_71) ,否则如果你不知道你有什么文件夹名称,那么打开Java文件夹找到它,你会看到文件夹名称是什么,但您必须在BIN文件夹中,然后运行此命令。 Today I have got my SHA1 value in a cmd command window by the above procedure. 今天我通过上面的过程在cmd命令窗口中得到了我的SHA1值。

SNAPSHOT: 快照:

在此输入图像描述


#4楼

I want to add one thing with the answer given by Softcoder . 我想在Softcoder给出的答案中添加一个东西。 I have seen some people couldn't give their debug.keystore path correctly on the command line . 我看到有些人无法在command line上正确地给出他们的debug.keystore路径。 They see that they are doing the exact process accepted above, but it is not working. 他们看到他们正在做上面接受的确切过程,但它不起作用。 At that point try to drag the debug.keystore and drop it on the command line. 此时尝试拖动debug.keystore并将其放在命令行上。 It will help if the accepted answer is not working for you. 如果接受的答案不适合您,这将有所帮助。 Do the full process without any hesitation. 毫不犹豫地完成整个过程。 It was a nice answer. 这是一个很好的答案。


#5楼

对于Mac,这非常有效:

keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android

#6楼

I just found the case to get SHA-1 in Android Studio: 我刚刚找到了在Android Studio中获取SHA-1的案例:

  1. Click on your package and choose New -> Google -> Google Maps Activity 点击您的包,然后选择新建 - > Google - > Google地图活动
  2. Android Studio redirects you to google_maps_api.xml Android Studio会将您重定向到google_maps_api.xml

And you will see all you need to get google_maps_key . 您将看到获取google_maps_key所需的google_maps_key

图片

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值