简体   繁体   中英

White screen in google map on Android app

I have a problem in showing google map.

In an android studio emulator I see the google map, but in the mobile app I see this:

White screen without positions in galaxy S2 and S4, so it's not the mobile.

I set the api key from google.

It's my manifest:

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

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

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

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity android:name="com.matchrace.matchrace.MainActivity" >
        </activity>
        <activity android:name="com.matchrace.matchrace.AdminActivity" >
        </activity>
        <activity
            android:name="com.matchrace.matchrace.LoginActivity"
            android:windowSoftInputMode="adjustResize|stateVisible" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

        <!-- API Key using my PC -->
        <!-- <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="AIzaSyAbk57eU-y_eB3ywDZanb5pAh-qOEGQB0o" /> -->

        <!-- API Key using my Laptop -->
        <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="AIzaSyANCANO4oFrUWMtzPHSVA-e7ely8mXCRqo" />

        <activity android:name="com.matchrace.matchrace.MenuActivity" >
        </activity>
    </application>

</manifest>

I set focus like this:

LatLng latLng = new LatLng(32.056286, 34.824598);
CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(latLng, C.ZOOM_LEVEL);
googleMap.animateCamera(cameraUpdate);

When you sign api,you get new certificate.

Save this sertificate and you have to put this md5 key to android manifest file.

I had the same problem, where the emulator works fine, but on a real device, a Samsung tablet, I was getting a white map.

Finally, I found the reason: the WiFi connection was accidentally lost.

If you see the white map, then the first thing you should check is your WiFi connection.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM