lll
lll

Reputation: 173

Google Maps for android not rendering

I recently updated all my tools to sdk 23. When i create a Google Maps Activity using the activity wizard, it creates successfully, but when i run it on a device, the map doesnt show. All i get is a google logo in the bottom left corner.

What I've tried:

-Create API Key using SHA-1 found in debug.keystore

-Regenerated API Key and verified package name

-Made sure i enabled 'Google Maps v2 for Android' and not 'Google Maps v2'

-Looked at and tried all the related solutions on this site that i could find(+-10), none of which worked

-Made sure i had google-play-services as a project dependency

-Made sure Google Play Services was updated along with the rest of the tools

My Manifest:

<!--
     The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
     Google Maps Android API v2, but you must specify either coarse or fine
     location permissions for the 'MyLocation' functionality. 
-->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<permission android:name="com.venon.ranger.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>
<uses-permission android:name="com.venon.ranger.permission.MAPS_RECEIVE"/>
<uses-feature android:glEsVersion="0x00020000" android:required="true"/>

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".MainActivity">

    </activity>

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

    <activity
        android:name=".MapsActivity"
        android:label="@string/title_activity_maps">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

    <receiver android:name=".PushReceiver">
        <intent-filter>

            <!-- Do not modify this -->
            <action android:name="pushy.me" />
        </intent-filter>
    </receiver>

    <!-- Pushy Update Receiver -->
    <!-- Do not modify - internal BroadcastReceiver that restarts the listener service -->
    <receiver android:name="me.pushy.sdk.receivers.PushyUpdateReceiver">
        <intent-filter>
            <action android:name="android.intent.action.PACKAGE_REPLACED" />

            <data android:scheme="package" />
        </intent-filter>
    </receiver>

    <!-- Pushy Boot Receiver -->
    <!-- Do not modify - internal BroadcastReceiver that restarts the listener service -->
    <receiver android:name="me.pushy.sdk.receivers.PushyBootReceiver">
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED" />
        </intent-filter>
    </receiver>

    <!-- Pushy Socket Service -->
    <!-- Do not modify - internal socket background service -->
    <service android:name="me.pushy.sdk.services.PushySocketService" />
</application>

My App-Gradle:

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.3"

defaultConfig {
    applicationId "com.venon.ranger"
    minSdkVersion 16
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
   compile fileTree(dir: 'libs', include: ['*.jar'])
   testCompile 'junit:junit:4.12'
   compile 'com.android.support:appcompat-v7:23.0.0'
   compile 'com.google.android.gms:play-services-maps:8.4.0'

}

My MapActivity.xml

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:apiKey = "AIzaxxxxxxxxxxxxxxxxxxxxxxxxxx"
tools:context="com.venon.ranger.MapsActivity" />

My MapActivity.java

package com.venon.ranger;

import android.os.Bundle; 
import android.support.v4.app.FragmentActivity;

import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;

public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {

private GoogleMap mMap;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_maps);
    // Obtain the SupportMapFragment and get notified when the map is ready to be used.
    SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
            .findFragmentById(R.id.map);
    mapFragment.getMapAsync(this);



}


/**
 * Manipulates the map once available.
 * This callback is triggered when the map is ready to be used.
 * This is where we can add markers or lines, add listeners or move the camera. In this case,
 * we just add a marker near Sydney, Australia.
 * If Google Play services is not installed on the device, the user will be prompted to install
 * it inside the SupportMapFragment. This method will only be triggered once the user has
 * installed Google Play services and returned to the app.
 */
@Override
public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;

    // Add a marker in Sydney and move the camera
    LatLng disturbance = new LatLng(-34, 151);

    mMap.addMarker(new MarkerOptions().position(disturbance).title("Disturbance"));
    mMap.moveCamera(CameraUpdateFactory.newLatLng(disturbance));

}
}

I am fresh out of ideas.

Upvotes: 0

Views: 1834

Answers (1)

Android Enthusiast
Android Enthusiast

Reputation: 4960

This problem is usually related to the Maps API Key used to sign manifest. You need to make sure you use your debug keystore when you create an API key in the Google API console.

When you are ready to launch the app to Market, set the android:debuggable="false" in the AndroidManifest.xml and use the Signed API key.

When using the signed API key, the MapView will show up ONLY when the app is installed from the Android Market. So, the MapView will show up.

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" > 

Here's a related Stack overflow ticket which discuss Google Maps not rendering maps: Android and strange error with maps from google

Upvotes: 1

Related Questions