Google Maps works but MapFragment does not work

advertisements

i developed an app which uses MapActivity. I have associated an API-KEY in Manifest and i´m using the google play services for the map in Gradle 10.2.0 ...

My Problem:

In my AVD and on my real Device (Galaxy s6 with Nougat, Android 7) i can see the Map and it´s loading correctly. But on some Devices it doesn´t, i don´t know why? Same API Key of course. I´m using the supportMapFragment.

for example on these phones the Map stays grey with the google logo on the bottom left corner.

also in Galaxy s3 with 4.03 and 4.1.1 it doesn´t work. On Xiaomi Mi MAX it works.

Manifest

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="ibas.locatixteamviewer">

<!--
     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" />
<!--
     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.
-->
<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">

    <!--
         The API key for Google Maps-based APIs is defined as a string resource.
         (See the file "res/values/google_maps_api.xml").
         Note that the API key is linked to the encryption key used to sign the APK.
         You need a different API key for each encryption key, including the release key that is used to
         sign the APK for publishing.
         You can define the keys for the debug and release targets in src/debug/ and src/release/.
    -->
    <meta-data
        android:name="com.google.android.geo.API_KEY"
        android:value="@string/google_maps_key" />

    <activity
        android:name=".MapsActivity"
        android:label="@string/title_activity_maps"></activity>
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:noHistory="true"
        android:theme="@style/AppTheme.NoActionBar">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name=".ListActivity"
        android:label="@string/title_activity_list"
        android:theme="@style/AppTheme.NoActionBar" />
    <activity
        android:name=".FahrzeugActivity"
        android:label="@string/title_activity_fahrzeug"
        android:theme="@style/AppTheme.NoActionBar" />
    <activity
        android:name=".WebActivity"
        android:label="@string/title_activity_web"
        android:theme="@style/AppTheme.NoActionBar" />
    <activity
        android:name=".ListMapsActivity"
        android:label="@string/title_activity_list_maps"></activity>
</application>

activity_maps.xml

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
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"
tools:context="ibas.locatixteamviewer.MapsActivity">

<!--<Button-->
    <!--android:id="@+id/button1"-->
    <!--android:layout_width="wrap_content"-->
    <!--android:layout_height="wrap_content"-->
    <!--android:background="#359c5e"-->
    <!--android:layout_alignParentTop="true"-->
    <!--android:layout_alignParentEnd="true"-->
    <!--android:padding="8dp"-->
    <!--android:layout_margin="5dp"-->
    <!--android:src="@drawable/menu_car_side_7_white"-->
    <!--android:textColor="#ffffff" />-->

</fragment>

Gradle

compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.google.android.gms:play-services-maps:10.2.0'
compile 'com.android.support:design:25.2.0'
compile 'com.android.volley:volley:1.0.0'
compile 'com.android.support:recyclerview-v7:25.2.0'
testCompile 'junit:junit:4.12'

}

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "ibas.locatixteamviewer"
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }


Add this in your manifest top of <application> tag

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

<uses-permission android:name="android.permission.INTERNET" />
<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.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />