当前位置: 动力学知识库 > 问答 > 编程问答 >

Android Maps api release key not working

问题描述:

I looked over all the stackoverflow questions related to this, but nothing worked. Sorry if this is asked already.

I have the Google maps api integrated into my app, and everything works fine in development. I got a debug api key based on the debug.keystore file and it works just fine.

Then I went ahead and got a release api key based on the keystore file that I use to sign the app. However, all I see are grey tiles - the maps don't show up. I have the uses-library tag inside of my application tag in the manifest. I have the permission for the internet in the manifest, as well as android:debuggable="false" (though this doesn't seem to change anything).

What else could I be missing?

网友答案:

I had the same problem.

How I've solved it:

It is important to make a new(!) API key for your release-keystore because the old API key generated for debug keystore will not work with release keystore. Here it is the procedure how to do it: https://developers.google.com/maps/documentation/android/mapkey#getfingerprint

In few words:

  1. make a fingerprint (MD5) for your keystore, e.g. by this batch file:

    @echo off "c:\Program Files\Java\jdk1.7.0\bin\keytool.exe" -v -list -keystore my-release-key.keystore > my-release-md5-fingerprint.txt

    echo your google api key (md5) saved to the file my-release-md5-fingerprint.txt

    pause

  2. Go to the google site where APi is generated: http://code.google.com/android/maps-api-signup.html

And copy-paste to the appropriate field your MD5 fingerprint which looks like the following 94:1E:43:49:87:73:BB:E6:A6:88:D7:20:F1:8E:B5:98 (no extra spaces or additional symbols allowed).

网友答案:

You should create a Release key from another link. Debug key and Release key are different. See here for "how to create debug key and release key differently": http://chocotech.blogspot.com/2012/10/get-debug-key-and-release-key-for.html

网友答案:

In your MapView you have to specify your ApiKey :

<com.google.android.maps.MapView
    android:id="@+id/mapView"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:apiKey="@string/mapKey"
    android:layout_below="@+id/email"
    android:clickable="true"
    android:enabled="true" >
</com.google.android.maps.MapView>

where mapKey is you ApiKey (here I define it in my Strings).

分享给朋友:
您可能感兴趣的文章:
随机阅读: