Google maps was working on a published app and now for some reason it has just stopped displaying the map. Here is the manifest:
<manifest
.....
<permission
android:name="com.x.x.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.x.x.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<!-- Maps API needs OpenGL ES 2.0. -->
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name">
.....
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="@string/map_key" />
<meta-data
android:name="com.google.android.gms.version"
android:value="4030500" />
</application>
I have got the debug and release SHA-1 keys from the debug and release store and put them on the Google Maps Android API V2 and have put the API key in to the manifest (hardcoded and in strings.xml).
Here is the layout:
<fragment
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.SupportMapFragment"/>
Here is the how I try to access the SupportMapFragment from the fragment being displayed:
private void setUpMapIfNeeded()
{
SupportMapFragment fragment = (SupportMapFragment)fManager.findFragmentById(R.id.map);
if (fragment != null)
{
mMap = fragment.getMap();
}
// Check if we were successful in obtaining the map.
if (mMap != null)
setUpMap();
}
However fragment always returns null. At one point I was getting the failed to Authorise message, but currently I dont see that. Only a blank map.
Update: It does not seem to be a problem with the keys, it is to do with
android:name="com.google.android.gms.maps.SupportMapFragment"
in the layout file. When I try to get the fragment by id it returns null. The frustrating thing is that I have created a test project where the set up is basically identical and it works. Yet when I try the same code in this project it is not working. Both projects are pointing at the same Google Play Services library project and they both point to the Support Library v4. Even the manifest has the same entries. Also, if I replace SupportMapFragment with MapFragment it works ok.