Android: Google Maps not displaying

匆匆过客 提交于 2019-11-29 06:26:17
Rarw

This problem is usually related to the map API key used to sign manifest. Take a look at this post and this one which describe the same error you are experiencing. In both cases it is because the API key they used was created with the wrong keystore. You need to make sure you use your debug keystore when you create an API key in the Google API console if you are going to be testing from eclipse.

Basically you are mixing deprecated Android API v1 with the new API v2.

The easiest way to migrate is to remove all v1 related code and start from scratch, following this link: https://developers.google.com/maps/documentation/android/start

If you have several packages in your app beware when you create the API key you must use the package name that included in top of the android mainfest.xml file

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    **package="com.xxx.xxx"**
    android:versionCode="1"
    android:versionName="1.0" > 

well actually I had lived this problem and it makes me crazy. after I found the solution. very simple:

1- in your project, google_maps_api.xml just check the web link is for your package name, if your package name exist and correct. go to page and get the key

To get one, follow this link, follow the directions and press "Create" at the end:

https://console.developers.google.com/flows/enableapi?apiid=maps_android_backend&keyType=CLIENT_SIDE_ANDROID&r=...

2- just create new gooogle maps activity project get the SHA-1 code.

dont forget SHA-1 code is same in your other project but web link is uniqu for each your program

go to developper console enable maps api for your device and then copy your key and paste in values->google_maps_api.xml . It works Use Android key(auto created by google service) if on android devices

After days of struggle, I found the issue. In my manifest I had the key value stored in an xml file and it didn't work. Now i have

<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="AIzxxxxxxxxxxxxxxxxxxxxxxxkey" />    and it works.

Just removed the xml file... Hope it helps!

I had the same problem. The problem was in my manifest file. Check if the google maps key you have stored IN STRING.xml and google maps key in google_maps_api.xml does not have same name.

One most probable reason for this is you have not added API key in the project manifest file. Simplest way to fix this is go to the "google_maps_api.xml" file and copy the link in the file and paste it in the browser. Click on the create button in the link and copy the api key that is being generated after that and paste it in the AndroidManifest.xml in the place of "Your Api Key" which is inside the meta-data tag, compile the project this will fix the issue.

May be this is because of the Google API key you have to make put google_maps_api.xml file in the values folder and paste the correct API key in it. and also you have to put this code in AndroidManifest.xml file

 <application>
 <meta-data
        android:name="com.google.android.geo.API_KEY"
        android:value="YOUR_API_KEY" />

 </application>

If above all answers do not work at all .Then use another Emulator . It worked for me.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!