Android Google Maps API v2没有显示任何内容

时间:2014-05-12 14:40:03

标签: android google-maps google-maps-api-2

我尝试使用Google Maps API v2,到目前为止,我已经阅读了很多问题和答案。它可以工作,从不崩溃,但它只显示一个白色的显示屏,左下角有谷歌地图标志,右下角有两个按钮,用于缩小/缩小,这就是全部。为什么呢?

清单:

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

    <permission
        android:name="com.descoper.rom.permission.MAPS_RECEIVE"
        android:protectionLevel="signature" />
    <uses-permission android:name="com.descoper.rom.permission.MAPS_RECEIVE" />


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

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

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

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/CustomActionBarTheme"
         >

         <meta-data android:name="com.google.android.gms.version" 
             android:value="@integer/google_play_services_version" />

        <activity
            android:name="com.descoper.rom.MainActivity"
            android:label="@string/app_name"
            android:screenOrientation="landscape"
            android:installLocation="preferExternal" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

        <activity
            android:name="com.descoper.rom.Galerie"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.descoper.rom.GalerieAdapter"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.descoper.rom.Item"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.descoper.rom.Romania"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.descoper.rom.Maps"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
        </activity>
        <!-- Goolge Maps API Key -->
        <meta-data
     android:name="com.google.android.maps.v2.API_KEY"
     android:value="Here is my generated API KEY " />

    </application>

</manifest>

maps.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"/>

Maps.java:

package com.descoper.rom;

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

public class Maps extends Activity {

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

    }
}

logcat - 可能的错误:

05-12 11:44:06.210: E/JavaBinder(729): *** Uncaught remote exception!  (Exceptions are not yet supported across processes.)
05-12 11:45:01.070: E/libEGL(52): called unimplemented OpenGL ES API
05-12 11:45:01.070: E/libEGL(52): called unimplemented OpenGL ES API
05-12 11:45:01.080: E/libEGL(52): called unimplemented OpenGL ES API
05-12 11:45:01.080: E/libEGL(52): called unimplemented OpenGL ES API
05-12 11:45:01.080: E/SurfaceFlinger(52): glCheckFramebufferStatusOES error -507375258
05-12 11:45:01.080: E/SurfaceFlinger(52): got GL_FRAMEBUFFER_COMPLETE_OES error while taking screenshot
05-12 11:45:01.080: E/libEGL(52): called unimplemented OpenGL ES API
05-12 11:45:01.080: E/libEGL(52): called unimplemented OpenGL ES API

3 个答案:

答案 0 :(得分:2)

可能重复:Google maps Android only white screen is shown

这不是一个完整的答案,因为没有足够的信息给予调试。你应该在启动地图时查看logcat中的警告,并发布它们以便我们可以更好地调试,因为它们通常会告诉你问题是什么。您是否在Android Maps API V2下的API控制台中注册了任何调试/生产密钥库SHA1密钥?有时问题就像在Maps API V2下注册而不是Android Maps API V2一样简单。此外,它还需要一段时间(约15分钟到一小时)才能上线。

此外,请确保您的密钥库中没有注册多个API密钥。您可以拥有多个与SHA1密钥关联的软件包,反之亦然,但您不能拥有与密钥库SHA1关联的多个API密钥

作为指南,请按照以下链接逐字:https://developers.google.com/maps/documentation/android/start

答案 1 :(得分:1)

您使用的是哪种类型的密钥库?

通常有两个键调试键和释放键。在签署应用程序时,您希望使用发布密钥。为此,你想与签名的apk

进行比较

第1步:

比如说你的apk名称是A,你正在为A.apk签名并创建一个密钥库,即A.keystore将在某个驱动器位置创建。让我们在E盘中考虑它。

第2步:

现在找到C盘中的jdk(考虑到Windows并分配C盘)

C:\ Program Files \ Java \ jdk1.7.0 \ bin&gt; keytool -list -v -keystore E:\ A.keystore -alias A

因此它将创建SHA-1 fingure print

在谷歌地图控制台中复制并粘贴它,它将生成一个密钥。在地图中使用它。

答案 2 :(得分:0)

遇到了这个问题。确保安装发布版本而不是调试版本。调试版本未使用您的证书签名,这就是Maps无法加载的原因。我花了一段时间来搞清楚!