2

I have google maps configured and set (or so I think), but my device comes up with a blank screen when I launch the app.

I believe I have all the proper settings and requirements to utilize the google maps application. Kindly let me know if I am missing anything.

Activity is here:

    package com.example.maptesting;

    import android.os.Bundle;
    import android.app.Activity;
    import android.app.Fragment;
    import android.support.v4.app.FragmentActivity;
    import android.view.Menu;

    public class MainActivity extends FragmentActivity {


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    }

XML layout here:

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity" >

    <fragment

        android:id="@+id/map"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        class="com.google.android.gms.maps.SupportMapFragment" />

</RelativeLayout>

and Manifest here:



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

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

    <permission
        android:name="com.example.maptesting.permission.MAPS_RECEIVE"
        android:protectionLevel="signature" >
    </permission>

    <uses-permission android:name="com.example.maptesting.permission.MAPS_RECEIVE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

    <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" >
        <activity
            android:name="com.example.maptesting.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>

        <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="     
I know this isn't the key but rest assured I have it correctly configured" />
    </application>

</manifest>

Thanks for everyone's assistance

Blorgbeard
  • 101,031
  • 48
  • 228
  • 272
user1888771
  • 107
  • 1
  • 4
  • 16

3 Answers3

0

I had the same problem one week ago. I changed a bit the way the map is loaded (also for other reasons) and now everything works fine.

Here My solution:

Layout

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >

    <FrameLayout
        android:id="@+id/map_container"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >
    </FrameLayout>

</RelativeLayout>

Activity

package com.example.maptesting;

import android.os.Bundle;
import android.app.Activity;
import android.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;

public class MainActivity extends FragmentActivity {

private MapFragment mMapFragment;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mMapFragment = MapFragment.newInstance();
     FragmentTransaction fragmentTransaction =
             getFragmentManager().beginTransaction();
     fragmentTransaction.add(R.id.map_container, mMapFragment);
     fragmentTransaction.commit();
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

}

Later you can retrieve the map object with

GoogleMap mMap = mMapFragment.getMap();

Hope this helps :)

DrChivas
  • 1,025
  • 8
  • 14
0

I had same problem for long time. It turned out that I wrongly selected option in API Consoles. Please turn on Google Android Map API v2 and not Google Maps API v2! Hope it will solve the issue ~

Hassan
  • 98
  • 2
  • 11
0

Android Map Api provides two authorization keys. One key for debug version of app and one key for release. Each time when the app is about to be sign for production - debug authorization key must be replaced with release one. Otherwise blank screen will be seen. Hope, this helps