English 中文(简体)
I can’t find the Android keytool
原标题:

I am trying to follow the Android mapping tutorial and got to this part where I had to get an API key.

I have found my debug.keystore but there does not appear to be a keytool application in the directory:

C:Documents and Settings	ward\.android>ls
adb_usb.ini      avd       debug.keystore  repositories.cfg androidtool.cfg  ddms.cfg  default.keyset

There is also no keytool in this directory:

C:Androidandroid-sdk-windows	ools>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 Eclipse as my editor and believe that I have downloaded all the latest SDK.

What am I doing wrong?

最佳回答

keytool comes with the Java SDK. You should find it in the directory that contains javac, etc.

问题回答

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).

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.

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.

So go to http://code.google.com/android/maps-api-signup.html and 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.

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 FilesJavajdk1.6.0_21in but try browsing to the Java folder and see what version you have and change the path accordingly.

After navigating to C:Program FilesJava<"your JDK version here">in in the command prompt, type

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.

(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")

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.

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.

Ok I did this in Windows 7 32-bit system.

step 1: go to - C:Program FilesJavajdk1.6.0_26in - and run jarsigner.exe first ( double click)

step2: locate debug.keystore, in my case it was - C:UsersMyPcName.android

step3: open command prompt and go to dir - C:Program FilesJavajdk1.6.0_26in and give the following command: keytool -list -keystore "C:UsersMyPcName.androiddebug.keystore"

step4: it will ask for Keystore password now. ( which I am figuring out... :-? )

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.)



Command to change the keystore password (look here): Keystore change passwords



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.

One needs simply to add a -v in the command in step 3. -like so:

Updated 4-Step Answer

Ok I did this in Windows 7 32-bit system.

step 1: go to - C:Program FilesJavajdk1.7.0in - and run jarsigner.exe first ( double click)

step2: locate debug.keystore (in Eclipse: Windows/Preferences/Android/build..), in my case it was - C:UsersMyPcName.android

step3: open command prompt and go to dir - C:Program FilesJavajdk1.7.0in and give the following command: keytool -v -list -keystore "C:UsersMyPcName.androiddebug.keystore"

step4: it will ask for Keystore password now. The default is android

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.

C:Program FilesAndroidAndroid Studiojrein

This seemed far harder to find than it needs to be for OSX. Too many conflicting posts

For MAC OSX Mavericks Java JDK 7, follow these steps to locate keytool:

Firstly make sure to install Java JDK:

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

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:

/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/bin

From bin directory you can use the keytool.

If you re using Android Studio for Windows to create a release keystore and signed .apk, just follow these steps:

1) Build > Generate Signed APK

2) Choose "Create New...", choose the path to the keystore, and enter all the required data

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

I haven t seen a need to use the command tool if you have an IDE like Android Studio.

In fact, eclipse export will call

java -jar android-sdk-windows	oolslibsdklib.jar com.android.sdklib.build.ApkBuilderMain

and then call com.android.sdklib.internal.build.SignedJarBuilder.

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.

Just wanted to share it...

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.





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签