我试图在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密钥,但不能运行项目。这就是为什么将配置更改为应用程序模式。见下图。

像这样。

第五步:快乐编码!!

其他回答

如果您正在使用Android Studio,您可以获得SHA-1和MD5证书指纹(debug, release…所有构建类型!!)快速通过Gradle任务:

签名报告

SHA-1和MD5证书在“消息日志”中显示。

Android插件(在Gradle应用中配置)为默认创建一个调试模式。

com.android.application

到密钥库的文件路由:

HOME/.android/debug.keystore

我建议附加调试。要构建的Keystore。gradle。为此放一个文件,调试。然后在Gradle app中添加signingconfigurations:

apply plugin: 'com.android.application'

    android {
        ................
        signingConfigs {
            debug {
                storeFile file("../app/debug.keystore")
                storePassword "android"
                keyAlias "androiddebugkey"
                keyPassword "android"
            }
            release {
                storeFile file("../app/debug.keystore")
                storePassword "android"
                keyAlias "androiddebugkey"
                keyPassword "android"
            }
        }
        ........
    }

额外:如果你想要创建发布,放一个文件,发布。Keystore,在应用程序文件夹中。(本例使用相同的debug.keystore。)

获取生产密钥库的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.

最近,Android Studio在其最新更新2020.3.1中已经从Gradle侧栏中删除了signingReport,但你仍然可以在Android Studio的终端中获得这些详细信息,只需编写以下命令: 窗口:

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

Linux与MacOS:

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

这在我的情况下是有效的:使用%USERPROFILE%,而不是给出路径。keystore文件自动存储在这个路径C:Users/用户名/.android:

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