Android Map is plain white screen - no errors

只谈情不闲聊 提交于 2019-12-31 03:45:43

问题


XML (activity_maptest.xml):

<?xml version="1.0" encoding="utf-8"?>
<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.MapFragment"/>

Java (Maptest.java):

package com.example.app;

import android.app.Activity;
import android.os.Bundle;

public class Maptest extends Activity {

    public class MapActivity extends Activity {

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

}

Manifest:

<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="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" />
<application
        android:allowBackup="true"
        android:icon="@drawable/icon_launcher"
        android:label="@string/app_name"
        android:theme="@style/Theme.AppCompat.Light.DarkActionBar" >
        .
        .
        .
        <activity
            android:name="com.example.app.Maptest"
            android:label="@string/title_activity_maptest" >
        </activity>

        <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="MY ACTUAL KEY" />
    </application>

When this page is loaded in my page is just white and there are no errors LogCat. I was following the google guide: https://developers.google.com/maps/documentation/android/start, but it appears I did something wrong?


回答1:


You have an Activity inside an Activity. Try removing one of them




回答2:


I had same issue the problem I had was That I forgot to enable google Map APi from developer console :-

hope it will help somebody.



来源:https://stackoverflow.com/questions/18618409/android-map-is-plain-white-screen-no-errors

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!