我试图在Android工作室,在Windows上做一个地图应用程序。如何查询SHA-1指纹证书编号?
当我使用Eclipse时,它就在Windows ->首选项-> Android ->构建下。但在Android Studio中,我找不到类似的选项。
我在文档里看到
Android Studio自动在调试模式下签署应用程序
从IDE运行或调试项目。
所以我试着设置我的Java bin路径,并运行以下命令,从这里取:
keytool -list -v -keystore "%USERPROFILE%\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android
然而,我得到了一个错误消息,说它是一个非法选项。
一步一步地,我如何在Android Studio中获得这些信息?
作为解决方案:我之前使用Eclipse生成的SHA-1指纹注册了我的应用程序。我可以使用相同的API键工作在我的项目在Android工作室?
(2017年更新)
第一步:在Android Studio的右上方单击Gradle选项。
步骤2:
——点击刷新(从Gradle栏点击刷新,你会看到项目的Gradle脚本列表)
——点击你的项目(你的项目名称表单列表(根))
——点击任务
——点击Android
双击signingReport(你会在Gradle控制台/运行栏中得到SHA1和MD5)
第三步:点击Android Studio底部的Gradle控制台选项,查看你的SHA1密钥。
步骤4:现在您获得了SHA密钥,但不能运行项目。这就是为什么将配置更改为应用程序模式。见下图。
像这样。
第五步:快乐编码!!
我的问题是一样的,因为我也把我的谷歌地图项目从Eclipse转移到Android Studio。我是这样解决我的问题的:
通过以下命令进入Java bin目录:
C:\Program Files\Java\jdk1.7.0_71\bin>
现在在命令窗口(CMD.EXE)中输入以下命令:
keytool -list -v -keystore c:\users\your_user_name\.android\debug.keystore -alias androiddebugkey -storepass android -keypass android
例子:
keytool -list -v -keystore c:\users\James\.android\debug.keystore -alias androiddebugkey -storepass android -keypass android
如果你不知道用户名,你也可以在cmd下写:
keytool -list -v -keystore "%USERPROFILE%\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android
你会得到SHA1。
然后我从https://code.google.com/apis/console创建了一个新密钥,因为我的包名称已经更改,然后在我的应用程序中使用这个密钥。它工作得很好。
确保您在jdkX.X的BIN文件夹中。X_XX(我的文件夹名称是jdk1.7.0_71),或者如果您不知道您的文件夹名称,那么可以通过打开Java文件夹找到它,您将看到文件夹名称,但您必须在BIN文件夹中,然后运行此命令。今天,我通过上述程序在cmd命令窗口中获得了我的SHA1值。
快照:
当创建一个新的“谷歌地图项目”时,在Android Studio V 1.5.1中,最后一个屏幕会打开google_maps_api.xml文件,并显示如下说明的屏幕:
资源:
TODO: Before you run your application, you need a Google Maps API key.
To get one, follow this link, follow the directions and press "Create" at the end:
https://console.developers.google.com/flows/enableapi?apiid=maps_android_backend&keyType=CLIENT_SIDE_ANDROID&r= YOUR SHA-1 + YOUR PACKAGE NAME
You can also add your credentials to an existing key, using this line:
YOUR SHA-1:YOUR PACKAGE NAME
Alternatively, follow the directions here:
https://developers.google.com/maps/documentation/android/start#get-key
Once you have your key (it starts with "AIza"), replace the "google_maps_key" string in this file.
<string name="google_maps_key" templateMergeStrategy="preserve" translatable="false">YOUR GOOGLE MAPS KEY</string>
要获得您的谷歌MAPS KEY,只需剪切并粘贴URL链接到您的浏览器中,并在创建新应用程序时遵循上面的说明。SHA-1和Package名称已经在给出的链接中,所以您不需要知道它们。然而,它们将在您的项目中的资源>Values>google_maps_api.xml文件中,当您按照创建项目的说明完成时。
获取生产密钥库的SHA1:
Build --> Generate Signed APK...
Create keystore with password and follow the steps
Go to your Mac/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/bin and drag the bin folder to the terminal after cd command to point at it so you can use the keytool tool. So, in terminal write cd (drag bin here) then press enter.
Then, copy and paste this in the terminal:
keytool -exportcert -alias Your_keystore_AliasName -keystore /Users/Home/Development/AndroidStudioProjects/YoutubeApp/app/YoutubeApp_keystore.jks -list -v
Erase my path and go where you stored your keystore and drag your keystone and drop it after -keystore in the command line so the path will get created.
Also, erase Your_keystore_AliaseName to put your alias keystone name that you used when you created it.
Press Enter and enter the password :)
When you enter the password, the terminal won't show that it receives keyboard entries, but it actually does, so put the password and press Enter even if you don't see the password is typed out.