Java 密钥库文件不存在

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/42663114/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 00:17:34  来源:igfitidea点击:

Keystore file does not exist

javaandroid

提问by FlameDra

I'm trying to use the Google Maps API in one of my projects and in the directions to set up the API credentials it wants me to add my application's SHA-1 signing-certificate fingerprint to the API.

我正在尝试在我的一个项目中使用 Google Maps API,并按照设置 API 凭据的说明将应用程序的 SHA-1 签名证书指纹添加到 API。

In the instructions, it says to use the following command to get the fingerprint:

在说明中,它说使用以下命令获取指纹:

keytool -list -v -keystore mystore.keystore

When I try to use it, both in the Android Studio terminal as well as cmd prompt in my application's directory I get the following error:

当我尝试使用它时,无论是在 Android Studio 终端中还是在我的应用程序目录中的 cmd 提示符中,我都会收到以下错误:

keytool error: java.lang.Exception: Keystore file does not exist: C:\Users\Name\.keystore

Note, my application is in D:\Projects\Android\AppName.

请注意,我的应用程序位于 D:\Projects\Android\AppName。

How do I get my SHA-1 signing-certificate to use with the Google Maps API?

如何让我的 SHA-1 签名证书与 Google Maps API 一起使用?

回答by singh.indolia

To find SHA-1 of your application, you can find like: To click on right side of your android studio click on gradle and then click on task-> android-> signingreport you will find your application sha-1 on below console. enter image description here

要查找您的应用程序的 SHA-1,您可以找到:单击 android studio 的右侧,单击 gradle,然后单击任务-> android-> 签名报告,您将在控制台下方找到您的应用程序 sha-1。 在此处输入图片说明

and to generate signing keystroke file you have to generate signing buid apk, to genrate signing build apk click on Build->generate signing apk->creaenew then follow the provedure you will find your keystroke file on your desire location.thanks

并生成签名击键文件,您必须生成签名生成 apk,生成签名生成 apk 单击 Build->generate signature apk->creaenew 然后按照证明,您将在所需位置找到您的击键文件。谢谢

回答by Rapunzel Van Winkle

The debug keystore file isn't in your application's directory, it's in your .android directory. If you're using Windows, it's probably in C:\Users\yourname\.android(where instead of "yourname" use your own User directory).

调试密钥库文件不在您的应用程序目录中,而是在您的 .android 目录中。如果您使用的是 Windows,它可能在C:\Users\yourname\.android(使用您自己的用户目录而不是“您的名字”)。

Once you know where it is, you can run the keytool like this:

一旦你知道它在哪里,你就可以像这样运行 keytool:

    keytool -list -v -keystore "C:\Users\yourname\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android

回答by Luan Si Ho

I found this from teamtreehouseforum. It solve my problem. try to follow these steps.

我从teamtreehouse论坛上找到了这个。它解决了我的问题。尝试按照这些步骤操作。

1) Open Command Promptby pressing Start+Rand typing cmd.exe.

1)按Start+R并键入 cmd.exe打开命令提示符

2) Using Windows Explorer, find where your JDKdirectory is located (Usually Program Files >> Java) and copy the path.

2) 使用Windows 资源管理器,找到JDK目录所在的位置(通常是 Program Files >> Java)并复制路径。

3) In Command Prompt, type cd followed by the directory of your JDK's bin directory. e.g: cd C:\Program Files\Java\jdk1.8.0_25\bin is the command I use (Yours may vary).

3) 在Command Prompt 中,键入 cd 后跟 JDK bin 目录的目录。例如: cd C:\Program Files\Java\jdk1.8.0_25\bin 是我使用的命令(您的可能会有所不同)。

4) Using Windows Explorer, find where your .android directory is located (Usually under Users >> [YOUR WINDOWS USERNAME]) and copy the path.

4) 使用 Windows 资源管理器,找到 .android 目录所在的位置(通常在用户 >> 下[YOUR WINDOWS USERNAME])并复制路径。

5) Now, use this command below:

5)现在,使用以下命令:

keytool -exportcert -alias androiddebugkey -keystore[PATH_TO_.ANDROID_DIRECTORY] -list -v

Replacing [PATH_TO_.ANDROID_DIRECTORY]with the path you copied. Note that you should be running this command in terminal/command prompt in your JDK's bin directory (You did this in Step 3).

替换[PATH_TO_.ANDROID_DIRECTORY]为您复制的路径。请注意,您应该在 JDK 的 bin 目录中的终端/命令提示符中运行此命令(您已在第 3 步中执行此操作)。

Mine is C:\Program Files\Java\jdk1.8.0_121\bin>keytool -exportcert -alias androiddebugkey -keystore C:\Users\HoSiLuan\.android\debug.keystore -list -v

我的是 C:\Program Files\Java\jdk1.8.0_121\bin>keytool -exportcert -alias androiddebugkey -keystore C:\Users\HoSiLuan\.android\debug.keystore -list -v

Remember to use C:\Users\HoSiLuan\.android\debug.keystoreinstead of ~/.android\debug.keystore. I still got the error when type this shorten way.

记得用 C:\Users\HoSiLuan\.android\debug.keystore而不是~/.android\debug.keystore. 输入这种缩短方式时,我仍然遇到错误。

Then enter password, normally it's android. After that, you'll see the list of certificates printed to the screen.

然后输入密码,一般是android。之后,您将看到打印到屏幕上的证书列表。

回答by Suleka_28

The easiest way of find the SHA-1 of your Android application is as follows: (NOTE: can only be done in Android Studio)

查找您的 Android 应用程序的 SHA-1 的最简单方法如下:(注意:只能在 Android Studio 中完成)

1) Open your project

1)打开你的项目

2) Click on the 'Gradle' tab in the right hand corner of the android studio window

2) 单击android studio 窗口右上角的“Gradle”选项卡

3) If no content is being shown click on the "Refresh all Gradle projects" icon in the left corner of the Gradle window (the blue icon)

3) 如果没有显示任何内容,请单击 Gradle 窗口左角的“刷新所有 Gradle 项目”图标(蓝色图标)

4) From the contents select the one that has your project name

4)从内容中选择具有您项目名称的内容

5) Go to 'Tasks' -> 'android' -> 'signingReport'

5)转到“任务”->“android”->“signingReport”

6) It will open a console, click the 'Toggle tasks executions/text mode' icon in the left top corner of it

6)它会打开一个控制台,点击它左上角的“切换任务执行/文本模式”图标

Now you will be able to see your SHA-1 information along with a bunch of other information about your project in the console

现在,您将能够在控制台中看到您的 SHA-1 信息以及有关您的项目的一系列其他信息

This link contains an image that highlights the above stated steps

此链接包含突出显示上述步骤的图像

After checking this make sure to change your configuration module to your current project. To do this follow the below steps:

检查后确保将您的配置模块更改为您当前的项目。为此,请执行以下步骤:

1)Click on the'select Run/Debug configuration' drop-down

1)点击“选择运行/调试配置”下拉菜单

2) Select app

2) 选择应用

3)Click on the'select Run/Debug configuration' drop-down again and select edit configurations

3)再次点击“选择运行/调试配置”下拉菜单,选择编辑配置

4)Select the 'General' tab and change the 'Module' to 'app', also tick the 'activate tool window' checkbox

4)选择“常规”选项卡并将“模块”更改为“应用程序”,同时勾选“激活工具窗口”复选框

5) press 'ok'

5)按“确定”

now you can run your project like before by pressing on the run button.

现在您可以通过按运行按钮像以前一样运行您的项目。

This link contains an image that highlights the above stated steps

此链接包含突出显示上述步骤的图像

hope this helped.

希望这有帮助。

回答by Kaveri

To get the SHA1 key in the command Provide the file path to the debug.keystore file in .android folder

获取命令中的 SHA1 密钥 提供 .android 文件夹中 debug.keystore 文件的文件路径

回答by Paras Arora

put this line in a single format =>

将此行放在单一格式中=>

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

don't do that half line of code in upper line and half code in lower line and one more important thing remove /after -v/to make it -v -alias ....so on

不这样做的上线和半码的代码,半年线,以较低线路和一个更重要的删除/-v/,使其-v -alias ....等等

回答by Rashid Iqbal

here is the command lineinstructions password is android

这里是命令行说明密码是android

keytool -exportcert -list -v -alias androiddebugkey -keystore C:\Users\rashi\.android\debug.keystore       

回答by Shark Deng

This link https://developers.google.com/games/services/console/enablinghas information on keytool

此链接https://developers.google.com/games/services/console/enabling包含有关 keytool 的信息

  1. Mac default debug keystone filepath is ~/.android/debug.keystore
  2. When using keytool -list -keystore ~/.android/debug.keystore, it will prompt to input password whose default value is android.
  1. Mac 默认调试 keystone 文件路径是 ~/.android/debug.keystore
  2. 使用keytool -list -keystore ~/.android/debug.keystore时会提示输入密码,默认为android

回答by Alex S

for windows:
1. open console where you android project located
2. run keytool, if tells you that command unknown go to 3, otherwise, go to 4
3. navigate to folder with Java JDK, like: cd 'C:\Program Files\Java\jdk1.8.0_211\bin\'or install JDK if not found
4. execute
.\keytool.exe -list -v -keystore PROJECT-FOLDER\android\app\debug.keystore -alias androiddebugkey -storepass android -keypass android

对于 Windows:
1. 打开您的 android 项目所在的控制台
2. 运行keytool,如果告诉您命令未知,请转到 3,否则,请转到 4
3. 导航到带有 Java JDK 的文件夹,例如:cd 'C:\Program Files\Java\jdk1.8.0_211\bin\'如果未找到,则安装 JDK
4.执行
.\keytool.exe -list -v -keystore PROJECT-FOLDER\android\app\debug.keystore -alias androiddebugkey -storepass android -keypass android

回答by Manchanayakage Shalika Prasad

If you firstly install android, don't create any project yet or debug.keystore file delete own you, then you create new android sample project. and try to run "signingReport"

如果您首先安装 android,还没有创建任何项目或者 debug.keystore 文件删除了您,那么您将创建新的 android 示例项目。并尝试运行“signingReport”