Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Maps Android V2 - Blank Screen

I am implementing google maps for android. I created a test application and inserted all the permissions etc in that application and the application worked flawlessly.

But when I try and copy the same code to my real application it shows me blank screen on the android activity.Although I've updated the package name in the google api console.

Here's what my Test Project Manifest Looks Like :

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

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="17" />

<permission
    android:name="com.example.mapstutorial.permission.MAPS_RECEIVE"
    android:protectionLevel="signature"/>
<uses-permission android:name="com.example.mapstutorial.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>

<uses-feature
    android:glEsVersion="0x00020000"
    android:required="true"/>

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
<uses-library android:name="com.google.android.maps" />
    <meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="my api key"/>

    <activity
        android:name="com.example.mapstutorial.MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

</manifest>

and here's what my real project manifest looks like :

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.shop.shoppinglist"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17" />

<permission      android:name="com.shop.addtask.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>
<permission      android:name="com.shop.shoppinglist.permission.C2D_MESSAGE"    android:protectionLevel="signature" />

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />

<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="com.shop.addtask.permission.MAPS_RECEIVE"/>
<uses-permission android:name="com.shop.shoppinglist.permission.C2D_MESSAGE" />

<uses-feature
    android:glEsVersion="0x00020000"
    android:required="true"/>

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:allowBackup="true"
    android:theme="@style/AppTheme" >

    <uses-library android:name="com.google.android.maps"/>
    <meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="my api key"/>

    <activity
        android:name=".Login_Activity"
        android:label="@string/title_activity_main" 
        android:theme="@style/Theme.Sherlock" 
        android:screenOrientation="portrait" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

I updated the package name to com.shop.addtask in my console fingerprint but still it shows me the white screen.What could cause the problem ? The apikey I've used is same in both of the applications. But it works on test application not on the real app.

  • I've created the api key using the fingerprint
  • I've switched on google maps android v2 in the console
  • I am using the same api key as mentioned in the console.

So these things are correct and the problem cannot be caused by one of them.

like image 525
Mj1992 Avatar asked Mar 27 '13 12:03

Mj1992


People also ask

Why is my Google Maps screen blank?

This problem generally happens when you have too many bugged cookies in your browser or cached data in your Android app. The best solution to blank Google Maps is getting rid of the unwanted data from your mobile app or web browser.

Why is my Google Maps not loading anything?

Clear the app's cache & data On your Android phone or tablet, open the Settings app . Tap Apps & notifications. Follow the steps on your device to find the Maps app. After you select the app, storage & cache options should be available.

How do I fix Google Maps on my Android?

The first thing to try is restarting the app. Completely close the app, then tap its tile to start Google Maps again so that it re-syncs with Google's servers. This tends to solve the problem for most iPhone users. You can also try restarting your phone completely.


3 Answers

2 possible reasons:

1. this part:

 <uses-library android:name="com.google.android.maps"/>
<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="my api key"/>

should right before the closing application tag.

2. Most likely you have some sort of problem with your key. Try to generate a new by deleting the debug.keystore folder and running a project. then register it again via the console.

you can use this guide I wrote to do just that:

Google Map API V2 key

Update:

Check this for a second:

<permission      android:name="com.shop.addtask.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>

it looks that the package you set here is not the package of your application and should be:

  <uses-permission android:name="com.shop.shoppinglist.permission.MAPS_RECEIVE"/>
  <permission      android:name="com.shop.shoppinglist.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>
like image 97
Emil Adz Avatar answered Oct 04 '22 03:10

Emil Adz


<permission      android:name="com.shop.addtask.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>
<uses-permission android:name="com.shop.addtask.permission.MAPS_RECEIVE"/>

package name is

package="com.shop.shoppinglist"

Hope below link helps you, AndroidManifest.xml for Google Maps Android API v2

try this,

<permission      android:name="com.shop.shoppinglist.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>
<uses-permission android:name="com.shop.shoppinglist.permission.MAPS_RECEIVE"/>
like image 22
Amol Sawant 96 Kuli Avatar answered Oct 04 '22 01:10

Amol Sawant 96 Kuli


After everything fails, try to uninstall the app and try it again. It worked in my case.

like image 20
user2654707 Avatar answered Oct 04 '22 02:10

user2654707