我找不到 Android keytool
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2997348/
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
I can’t find the Android keytool
提问by Tim
I am trying to follow the Android mapping tutorial and got to this part where I had to get an API key.
我正在尝试按照 Android 映射教程进行操作,并进入了我必须获取 API 密钥的部分。
I have found my debug.keystore
but there does not appear to be a keytool
application in the directory:
我找到了我的debug.keystore
但目录中似乎没有keytool
应用程序:
C:\Documents and Settings\tward\.android>ls
adb_usb.ini avd debug.keystore repositories.cfg androidtool.cfg ddms.cfg default.keyset
There is also no keytool
in this directory:
keytool
此目录中也没有:
C:\Android\android-sdk-windows\tools>ls
AdbWinApi.dll apkbuilder.bat etc1tool.exe mksdcard.exe
AdbWinUsbApi.dll ddms.bat fastboot.exe source.properties
Jet dmtracedump.exe hierarchyviewer.bat sqlite3.exe
NOTICE.txt draw9patch.bat hprof-conv.exe traceview.bat
adb.exe emulator.exe layoutopt.bat zipalign.exe
android.bat emulator_NOTICE.txt lib
I am using Eclipseas my editor and believe that I have downloaded all the latest SDK.
我使用Eclipse作为我的编辑器,并且相信我已经下载了所有最新的 SDK。
What am I doing wrong?
我究竟做错了什么?
回答by CommonsWare
keytool
comes with the Java SDK. You should find it in the directory that contains javac
, etc.
keytool
附带 Java SDK。您应该在包含javac
等的目录中找到它。
回答by malfunction
Okay, so this post is from six months ago, but I thought I would add some info here for people who are confused about the whole API key/MD5 fingerprint business. It took me a while to figure out, so I assume others have had trouble with it too (unless I'm just that dull).
好的,所以这篇文章是六个月前的,但我想我会在这里为那些对整个 API 密钥/MD5 指纹业务感到困惑的人添加一些信息。我花了一段时间才弄明白,所以我认为其他人也遇到了麻烦(除非我就是那么无聊)。
These directions are for Windows XP, but I imagine it is similar for other versions of Windows. It appears Mac and Linux users have an easier time with this so I won't address them.
这些说明适用于 Windows XP,但我想其他版本的 Windows 也是类似的。看起来 Mac 和 Linux 用户在这方面更轻松,所以我不会解决它们。
So in order to use mapviews in your Android apps, Google wants to check in with them so you can sign off on an Android Maps APIs Terms Of Service agreement. I think they don't want you to make any turn-by-turn GPS apps to compete with theirs or something. I didn't really read it. Oops.
因此,为了在您的 Android 应用程序中使用地图视图,Google 希望与他们核对,以便您可以签署 Android Maps APIs 服务条款协议。我认为他们不希望你制作任何转弯 GPS 应用程序来与他们的或其他东西竞争。我没有真正读过它。哎呀。
So go to http://code.google.com/android/maps-api-signup.htmland check it out. They want you to check the "I have read and agree with the terms and conditions" box and enter your certificate's MD5 fingerprint. Wtf is that, you might say. I don't know, but just do what I say and your Android app doesn't get hurt.
所以去http://code.google.com/android/maps-api-signup.html看看吧。他们希望您选中“我已阅读并同意条款和条件”框并输入您证书的 MD5 指纹。你可能会说,WTF 就是这样。我不知道,但只要按照我说的去做,你的 Android 应用就不会受到伤害。
Go to Start>Run and type cmd to open up a command prompt. You need to navigate to the directory with the keytool.exe file, which might be in a slightly different place depending on which version JDK you have installed. Mine is in C:\Program Files\Java\jdk1.6.0_21\bin
but try browsing to the Java folder and see what version you have and change the path accordingly.
转到开始>运行并键入 cmd 打开命令提示符。您需要导航到包含 keytool.exe 文件的目录,根据您安装的 JDK 版本,该目录的位置可能略有不同。我的是在,C:\Program Files\Java\jdk1.6.0_21\bin
但尝试浏览到 Java 文件夹,看看你有什么版本,并相应地更改路径。
After navigating to C:\Program Files\Java\<"your JDK version here">\bin in the command prompt, type
在命令提示符中导航到 C:\Program Files\Java\<"your JDK version here">\bin 后,键入
keytool -list -keystore "C:/Documents and Settings/<"your user name here">/.android/debug.keystore"
with the quotes. Of course <"your user name here"> would be your own Windows username.
用引号。当然,<"您的用户名>"将是您自己的 Windows 用户名。
(If you are having trouble finding this path and you are using Eclipse, you can check Window>preferences>Android>Build and check out the "Default Debug keystore")
(如果您在查找此路径时遇到问题并且您正在使用 Eclipse,您可以检查 Window>preferences>Android>Build 并检查“默认调试密钥库”)
Press enter and it will prompt you for a password. Just press enter. And voila, at the bottom is your MD5 fingerprint. Type your fingerprint into the text box at the Android Maps API Signup page and hit Generate API Key.
按回车键,它会提示你输入密码。只需按回车键。瞧,底部是您的 MD5 指纹。在 Android Maps API 注册页面的文本框中输入您的指纹,然后点击生成 API 密钥。
And there's your key in all its glory, with a handy sample xml layout with your key entered for you to copy and paste.
还有你的钥匙,它有一个方便的示例 xml 布局,你输入了你的钥匙,供你复制和粘贴。
回答by rav
Ok I did this in Windows 732-bit system.
好的,我在Windows 732 位系统中做了这个。
step 1: go to - C:\Program Files\Java\jdk1.6.0_26\bin - and run jarsigner.exe first ( double click)
第 1 步:转到 - C:\Program Files\Java\jdk1.6.0_26\bin - 首先运行 jarsigner.exe(双击)
step2: locate debug.keystore, in my case it was - C:\Users\MyPcName\.android
步骤 2:找到 debug.keystore,在我的例子中是 - C:\Users\MyPcName\.android
step3: open command prompt and go to dir - C:\Program Files\Java\jdk1.6.0_26\binand give the following command: keytool -list -keystore "C:\Users\MyPcName\.android\debug.keystore"
步骤 3:打开命令提示符并转到 dir - C:\Program Files\Java\jdk1.6.0_26\bin并给出以下命令: keytool -list -keystore "C:\Users\MyPcName\.android\debug.keystore"
step4: it will ask for Keystore password now. ( which I am figuring out... :-? )
步骤4:它现在会要求输入密钥库密码。(我正在弄清楚...... :-? )
update: OK in my case password was ′ android ′.
- (I am using Eclipse for android, so I found it here)
Follow the steps in eclipse:
Windows>preferences>android>build>..
( Look in `default Debug Keystore′field.)
更新:好的,在我的情况下密码是'android'。- (我使用 Eclipse for android,所以我在这里找到它)
按照 eclipse 中的步骤操作:
Windows>preferences>android>build>..
(查看“默认调试密钥库”字段。)
Command to change the keystore password (look here): Keystore change passwords
更改密钥库密码的命令(查看此处):密钥库更改密码
回答by fmak114
The 4-Step Answer above worked for me, but it returns the SH1-key... but Google asks for the MD5-key to generate your API key.
上面的 4-Step Answer 对我有用,但它返回 SH1 密钥……但 Google 要求提供 MD5 密钥来生成您的 API 密钥。
One needs simply to add a '-v' in the command in step 3. -like so:
只需在第 3 步的命令中添加一个“-v”即可。-像这样:
Updated 4-Step Answer
更新的 4 步答案
Ok I did this in Windows 7 32-bit system.
好的,我在 Windows 7 32 位系统中做了这个。
step 1: go to - C:\Program Files\Java\jdk1.7.0\bin - and run jarsigner.exe first ( double click)
第 1 步:转到 - C:\Program Files\Java\jdk1.7.0\bin - 首先运行 jarsigner.exe(双击)
step2: locate debug.keystore (in Eclipse: Windows/Preferences/Android/build..), in my case it was - C:\Users\MyPcName.android
step2:找到 debug.keystore(在 Eclipse 中:Windows/Preferences/Android/build..),在我的例子中是 - C:\Users\MyPcName.android
step3: open command prompt and go to dir - C:\Program Files\Java\jdk1.7.0\bin and give the following command: keytool -v-list -keystore "C:\Users\MyPcName.android\debug.keystore"
步骤 3:打开命令提示符并转到 dir - C:\Program Files\Java\jdk1.7.0\bin 并给出以下命令:keytool -v-list -keystore "C:\Users\MyPcName.android\debug.keystore"
step4: it will ask for Keystore password now. The default is 'android'
步骤4:它现在会要求输入密钥库密码。默认为“安卓”
回答by Goddard
I never installed Java, but when you install Android Studio it has its own version within the Android directory. Here is where mine is located. Your path may be similar. After that you can either put the keytool into your path, or just run it from that directory.
我从未安装过 Java,但是当您安装 Android Studio 时,它在 Android 目录中有自己的版本。这是我所在的地方。您的路径可能类似。之后,您可以将 keytool 放入您的路径中,或者直接从该目录运行它。
C:\Program Files\Android\Android Studio\jre\bin
回答by wired00
This seemed far harder to find than it needs to be for OSX. Too many conflicting posts
这似乎比 OSX 需要的更难找到。冲突的帖子太多
For MAC OSX Mavericks Java JDK 7, follow these steps to locate keytool
:
对于 MAC OSX Mavericks Java JDK 7,请按照以下步骤找到keytool
:
Firstly make sure to install Java JDK
:
首先确保安装Java JDK
:
http://docs.oracle.com/javase/7/docs/webnotes/install/mac/mac-jdk.html
http://docs.oracle.com/javase/7/docs/webnotes/install/mac/mac-jdk.html
Then type this into command prompt:
然后在命令提示符中输入:
/usr/libexec/java_home -v 1.7
/usr/libexec/java_home -v 1.7
it will spit out something like:
它会吐出类似的东西:
/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home
keytool
is located in the same directory as javac
. ie:
keytool
位于与javac
. IE:
/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/bin
From bin
directory you can use the keytool
.
从bin
目录中,您可以使用keytool
.
回答by whyoz
If you're using Android Studio for Windows to create a release keystore and signed .apk, just follow these steps:
如果您使用 Android Studio for Windows 创建发布密钥库并签署 .apk,只需按照以下步骤操作:
1) Build > Generate Signed APK
1)构建>生成签名APK
2) Choose "Create New...", choose the path to the keystore, and enter all the required data
2) 选择“Create New...”,选择keystore的路径,输入所有需要的数据
3) After your keystore (your_keystore_name.jks) has been created, you will then use it to create your first signed apk at a destination of your choosing
3) 创建您的密钥库 (your_keystore_name.jks) 后,您将使用它在您选择的目的地创建您的第一个签名的 apk
I haven't seen a need to use the command tool if you have an IDE like Android Studio.
如果您有像 Android Studio 这样的 IDE,我还没有看到需要使用命令工具。
回答by rogut
One thing that wasn't mentioned here (but kept me from running keytool altogether) was that you need to run the Command Prompt as Administrator.
这里没有提到的一件事(但让我完全无法运行 keytool)是您需要以管理员身份运行命令提示符。
Just wanted to share it...
只是想分享一下...
回答by Lawrence Chernin
No need to use the command line.
无需使用命令行。
If you FILE-> "Export Android Application" in the ADK then it will allow you to create a key and then produce your .apk file.
如果您在 ADK 中 FILE->“Export Android Application”,那么它将允许您创建一个密钥,然后生成您的 .apk 文件。
回答by diyism
In fact, eclipse export will call
其实eclipse export会调用
java -jar android-sdk-windows\tools\lib\sdklib.jar com.android.sdklib.build.ApkBuilderMain
and then call com.android.sdklib.internal.build.SignedJarBuilder.
然后调用 com.android.sdklib.internal.build.SignedJarBuilder。