5

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.

Mj1992
  • 3,404
  • 13
  • 63
  • 102
  • Are you getting any errors? If so can we see a stack trace? – Rarw Mar 27 '13 at 12:23
  • @kaya I've also deleted the android key from the console regenerated the `SHA1` and created a new key in console with that `SHA1` got the api key and used it.But still same result – Mj1992 Mar 27 '13 at 12:25
  • @Rarw The only red line I could see is this : `Could not find class 'maps.i.k', referenced from method maps.z.ag.a` – Mj1992 Mar 27 '13 at 12:28

8 Answers8

6

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"/>
Emil Adz
  • 40,709
  • 36
  • 140
  • 187
1
<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"/>
Amol Sawant
  • 13,842
  • 2
  • 20
  • 27
1

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

user2654707
  • 11
  • 1
  • 1
1

My problem was that I've changed the app's package name in the AndroidManifest file, but not the gradle.build's "applicationId" property, maybe that helps someone...

Analizer
  • 1,594
  • 16
  • 30
0

I had the same problem. I tried everything suggested on the different solutions on this error. Inclusively, I recreated my API key(including creating a new project) and nothing worked. After many, many hours wasted, I decided to delete all myapp user data on my android device, and magically this took care of the problem. My maps display correctly! Yay!!!

Android 4.2.2: Settings/Apps/YourApp/Clear data.

I hope this simple solution helps when everything else fails.

Sussetteh
  • 119
  • 3
0

ok, I have the same problem, I follow all the steps in the blogs and the google official page and not working, the solution is correct
<uses-library android:name="com.google.android.maps"/>
<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="my api key"/>
before close the application tag, but in the other case I found the solution, the problem is I generate SHA1 code in a macinthosh but I clone the repository and work in windows plataform but I found this problem, my solutions is that go to google console and generate other apikey but get the SHA1 code using this comand in windows,open the console and typed this code
cd C:\Program Files\Java\jre1.8.0_20\bin and press enter
next step copy and paste this code

keytool -list -v -keystore %HOMEPATH%\.android\debug.keystore -alias androiddebugkey -storepass android -keypass android

after press enter inside the console you show the SHA1 code copy and paste in a google console,is very important specified SHA1 code ";" and correct package ..

regards!!!

afzalex
  • 8,598
  • 2
  • 34
  • 61
  • 1
    Welcome to StackOverflow. You must visit [help center](http://stackoverflow.com/help) first. Try to make your code a little more readable. :) – afzalex Aug 28 '14 at 23:33
0

I 've got a similar problem with the map. After fixing all lib and key problems, I just saw a white sreen labled with "Google". The problem was, that I put the MapFragment into a ScrollView. After removing the ScrollView everything works fine. I can see the map.

BHuelse
  • 2,889
  • 3
  • 30
  • 41
0

Check whether you enabled Google Maps Android API or not

  • Open Google Map developer console.
  • Go to Library -> Google Maps Android APIs
  • If it is disabled, enable it. enter image description here
Vikas Chauhan
  • 51
  • 1
  • 2