谷歌地图V2显示白屏

时间:2014-01-29 11:25:10

标签: android google-maps

我只得到一个带缩放按钮的白色屏幕,并试图通过很多关于同一个问题的答案来解决这个问题,但没有什么对我有用。所以任何人都可以告诉我这里有什么问题。

Logcat:

01-29 16:48:48.703: D/dalvikvm(16910): DexOpt: couldn't find field Landroid/content/res/Configuration;.smallestScreenWidthDp
01-29 16:48:48.703: W/dalvikvm(16910): VFY: unable to resolve instance field 36
01-29 16:48:48.703: D/dalvikvm(16910): VFY: replacing opcode 0x52 at 0x0012
01-29 16:48:48.703: D/dalvikvm(16910): VFY: dead code 0x0014-0018 in Lcom/google/android/gms/common/GooglePlayServicesUtil;.b (Landroid/content/res/Resources;)Z
01-29 16:48:48.882: D/dalvikvm(16910): GC_CONCURRENT freed 194K, 46% free 3079K/5639K, external 412K/517K, paused 4ms+4ms
01-29 16:48:49.078: D/dalvikvm(16910): GC_CONCURRENT freed 129K, 42% free 3517K/6023K, external 412K/517K, paused 5ms+4ms
01-29 16:48:49.218: W/dalvikvm(16910): Unable to resolve superclass of Lmaps/p/r; (643)
01-29 16:48:49.218: W/dalvikvm(16910): Link of class 'Lmaps/p/r;' failed
01-29 16:48:49.218: W/dalvikvm(16910): Unable to resolve superclass of Lmaps/ao/an; (6521)
01-29 16:48:49.226: W/dalvikvm(16910): Link of class 'Lmaps/ao/an;' failed
01-29 16:48:49.226: W/dalvikvm(16910): Unable to resolve superclass of Lmaps/ae/i; (5640)
01-29 16:48:49.226: W/dalvikvm(16910): Link of class 'Lmaps/ae/i;' failed
01-29 16:48:49.226: E/dalvikvm(16910): Could not find class 'maps.ae.i', referenced from method maps.af.al.a
01-29 16:48:49.226: W/dalvikvm(16910): VFY: unable to resolve new-instance 5490 (Lmaps/ae/i;) in Lmaps/af/al;
01-29 16:48:49.226: D/dalvikvm(16910): VFY: replacing opcode 0x22 at 0x0091
01-29 16:48:49.257: D/dalvikvm(16910): VFY: dead code 0x0093-00a0 in Lmaps/af/al;.a (Landroid/view/LayoutInflater;Lcom/google/android/gms/maps/GoogleMapOptions;Z)Lmaps/af/al;
01-29 16:48:49.523: D/dalvikvm(16910): GC_CONCURRENT freed 263K, 43% free 3655K/6343K, external 412K/517K, paused 5ms+4ms
01-29 16:48:49.929: D/dalvikvm(16910): GC_EXTERNAL_ALLOC freed 232K, 41% free 3784K/6407K, external 437K/517K, paused 53ms
01-29 16:48:50.476: D/libEGL(16910): loaded /system/lib/egl/libGLES_hgl.so
01-29 16:48:50.609: D/dalvikvm(16910): GC_CONCURRENT freed 199K, 40% free 3933K/6535K, external 550K/1036K, paused 23ms+4ms
01-29 16:48:50.632: E/(16910): Creating OpenGL 1.1 Session
01-29 16:48:50.632: D/BRCM_EGL(16910): eglCreateContext() context: 0xf0920, VC context 1, Thread 16929
01-29 16:48:50.640: D/BRCM_EGL(16910): eglCreateWindowSurface() surface: 0x1e56e0, VC surface: 1, Thread: 16929
01-29 16:48:50.640: D/BRCM_EGL(16910): eglMakeCurrent(0xf0920, 0x1e56e0, 0x1e56e0) Thread: 16929

的manifest.xml

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

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

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<!-- Required to show current location -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

<!-- Required OpenGL ES 2.0. for Maps V2 -->
<uses-feature
    android:glEsVersion="0x00020000"
    android:required="true" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.vallabh.googlemapspractice.MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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



    <meta-data
         android:name="com.google.android.gms.version"
         android:value="@integer/google_play_services_version" />
    <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="My API key here"/>


</application>

</manifest>

Activity.java

package com.vallabh.googlemapspractice;

import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.SupportMapFragment;

import android.os.Bundle;
import android.app.Activity;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;
import android.widget.Toast;

public class MainActivity extends FragmentActivity 
{
GoogleMap map;
double lat;
double lan;
boolean flag = false;

@Override
protected void onCreate(Bundle onSavedInstanceState) 
{
    super.onCreate(onSavedInstanceState);
    setContentView(R.layout.activity_main);
    map = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
}

}

activity_main.xml中

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" 
android:orientation="vertical">

<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="wrap_content"
android:layout_height="match_parent" />

</LinearLayout>

4 个答案:

答案 0 :(得分:4)

我遇到同样的问题,就是在项目控制台上启用了Google Map APi。确保已启用Google Map API。Enable map API

答案 1 :(得分:2)

uses-permision文件中的AndroidManifest标记之前添加此标记:

<permission
    android:name="com.vallabh.googlemapspractice.permission.MAPS_RECEIVE"
    android:protectionLevel="signature" />

并添加此uses-permission代码:

<uses-permission android:name="com.vallabh.googlemapspractice.permission.MAPS_RECEIVE" />

答案 2 :(得分:0)

按照我在上一个问题中回答的this分步流程进行操作。如果有任何疑问,请告诉我。

答案 3 :(得分:0)

使用最新的Google文档,您似乎不再需要MAPS_RECEIVE了。

我将项目从一台机器运送到另一台机器时遇到了同样的问题。 原来问题是你需要重新生成密钥。

还记得你做过这一步吗? (关注https://developers.google.com/maps/documentation/android/start

keytool -list -v -keystore "%USERPROFILE%\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android

不同机器的SHA1序列不同。因此最终为我工作的是获得具有这种不同SHA1序列的新API密钥。然后在项目清单文件中使用此新API密钥。 这解决了我的问题。