谷歌地图API V2灰色屏幕 [英] Google Maps API v2 grey screen

查看:109
本文介绍了谷歌地图API V2灰色屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图创建和应用程序与谷歌地图连接。但屏幕的负载时这个图应该是它只是灰色的时候。我该如何解决这个问题?

这是我的logcat的重要消息。

 三月六日至11号:32:55.196:E /谷歌地图Android的API(11671):
确保以下对应的是在API控制台:套餐名称:我pacakage,
 API密钥:我的钥匙,
证书指纹:我的指纹
 

该活动

 进口android.os.Bundle;
进口android.view.Menu;

进口android.support.v4.app.FragmentActivity;

公共类mapPage扩展FragmentActivity {


    @覆盖
    保护无效的onCreate(包savedInstanceState){
        super.onCreate(savedInstanceState);
        的setContentView(R.layout.map_page);
    }

    @覆盖
    公共布尔onCreateOptionsMenu(功能菜单){
        //充气菜单;这增加了项目操作栏,如果它是present。
        。getMenuInflater()膨胀(R.menu.main,菜单);
        返回true;
    }

}
 

清单

 < XML版本=1.0编码=UTF-8&GT?;
<舱单的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    包=我的包
    安卓版code =1
    机器人:VERSIONNAME =1.0>

    <用途-SDK
        安卓的minSdkVersion =8
        机器人:targetSdkVersion =17/>
    <许可
    机器人:名称=我package.permission.MAPS_RECEIVE
    安卓的ProtectionLevel =签名/>
  <使用-权限的Andr​​oid:名称=我package.permission.MAPS_RECEIVE/>
  <! - 从谷歌地图图书馆/ AndroidManifest.xml中复制。 - >
  <用途-SDK
    安卓的minSdkVersion =8
    机器人:targetSdkVersion =16/>
  <使用-权限的Andr​​oid:名称=android.permission.ACCESS_NETWORK_STATE/>
  <使用-权限的Andr​​oid:名称=android.permission.INTERNET对/>
  <使用-权限的Andr​​oid:名称=com.google.android.providers.gsf.permission.READ_GSERVICES/>
  <! - 外部存储缓存。 - >
  <使用-权限的Andr​​oid:名称=android.permission.WRITE_EXTERNAL_STORAG​​E/>
  <! - 我的位置 - >
  <使用-权限的Andr​​oid:名称=android.permission.ACCESS_COARSE_LOCATION/>
  <使用-权限的Andr​​oid:名称=android.permission.ACCESS_FINE_LOCATION/>
  <! - 地图API需要OpenGL ES 2.0的。 - >
  <用途特征
    机器人:glEsVersion =0x00020000
    机器人:要求=真/>
  <! - 副本结束。 - >
    <应用
        机器人:allowBackup =真
        机器人:图标=@可绘制/ ic_launcher
        机器人:标签=@字符串/ APP_NAME
        机器人:主题=@风格/ AppTheme>

         &所述;元数据
      机器人:名称=com.google.android.maps.v2.API_KEY
      机器人:值=我的钥匙/>

        <活动
            机器人:名称=我package.MainActivity
            机器人:标签=@字符串/ APP_NAME>
            <意向滤光器>
                <作用机器人:名称=android.intent.action.MAIN/>

                <类机器人:名称=android.intent.category.LAUNCHER/>
            &所述; /意图滤光器>
        < /活性GT;

         <活动机器人:主名称=>
               < /活性GT;

         <活动机器人:名称=。mapPage>
              < /活性GT;

         <活动机器人:名称=。ThirdPartyWeb
          机器人:主题=@安卓风格/ Theme.Dialog>

              < /活性GT;

    < /用途>

< /舱单>
 

布局

 < XML版本=1.0编码=UTF-8&GT?;
< RelativeLayout的的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:layout_width =match_parent
    机器人:layout_height =match_parent>

  <片段的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
  机器人:ID =@ + ID /图
        机器人:layout_alignParentTop =真
        机器人:layout_centerInParent =真
        机器人:layout_height =250dp
        机器人:layout_width =FILL_PARENT
  类=com.google.android.gms.maps.SupportMapFragment/>

    < ImageView的
        机器人:layout_alignParentTop =真
        机器人:layout_centerInParent =真
        机器人:layout_height =50dp
        机器人:layout_width =FILL_PARENT
        机器人:背景=@色/ darkGrey/>

        <按钮
        机器人:layout_alignParentTop =真
        机器人:layout_marginTop =10dp
        机器人:layout_alignParentLeft =真
        机器人:ID =@ + ID /菜单按钮
        机器人:背景=@可绘制/ icon_menu
        机器人:layout_height =30dp
        机器人:layout_width =30dp/>

         <按钮
        机器人:layout_alignParentTop =真
        机器人:layout_marginTop =10dp
        机器人:layout_toRightOf =@ + ID /菜单按钮
        机器人:layout_marginLeft =20dp
        机器人:ID =@ + ID /
        机器人:背景=@可绘制/ icon_off
        机器人:layout_height =35dp
        机器人:layout_width =55dp/>

       <的EditText
        机器人:layout_alignParentTop =真
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_marginTop =10dp
        机器人:layout_toRightOf =@ + ID /
        机器人:layout_marginLeft =20dp
        机器人:layout_toEndOf =@ + ID /
        机器人:ID =@ + ID / seachBox
        机器人:提示=@字符串/搜索
        机器人:layout_height =35dp
        机器人:layout_alignParentEnd =真
        机器人:背景=@色/白/>

       <按钮
        机器人:layout_alignParentTop =真
        机器人:layout_alignParentRight =真
        机器人:layout_marginTop =10dp
        机器人:ID =@ + ID / searchButton
        机器人:背景=@可绘制/ graphic_search
        机器人:layout_height =35dp
        机器人:layout_width =20dp/>

       < ImageView的
        机器人:layout_above =@ + ID /新闻推送
        机器人:layout_centerInParent =真
        机器人:layout_height =35dp
        机器人:layout_width =FILL_PARENT
        机器人:背景=@色/ darkGrey/>

       <的TextView
           机器人:layout_alignParentLeft =真
           机器人:layout_height =WRAP_CONTENT
           机器人:layout_width =WRAP_CONTENT
           机器人:layout_above =@ + ID /新闻推送
           机器人:layout_marginBottom =11DP
           机器人:文字颜色=@色/白
           机器人:文本=@字符串/ news_feed
            机器人:textAppearance =:/>中的Andr​​oid ATTR / textAppearanceSmall?

        <的ListView
           机器人:layout_alignParentBottom =真
           机器人:ID =@ + ID /新闻推送
           机器人:layout_width =FILL_PARENT
           机器人:layout_height =WRAP_CONTENT>中

       < / ListView控件>



< / RelativeLayout的>
 

解决方案

确定问题就迎刃而解了。在谷歌API控制台,还有是二谷歌地图API V2的。我有一个只为谷歌地图API第2版,如果你只是它上面,它说,谷歌地图V2机器人。我打开一个以及和地图运行。

I'm trying to create and application that connects with Google maps. But when the screen loads where the map should be its just grey. How do I fix this?

The important message from my logcat.

06-11 03:32:55.196: E/Google Maps Android API(11671): 
Ensure that the following correspond to what is in the API Console: Package Name: my pacakage,
 API Key: my key, 
Certificate Fingerprint: my fingerprint

The Activity

import android.os.Bundle;
import android.view.Menu;

import android.support.v4.app.FragmentActivity;

public class mapPage extends FragmentActivity {


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

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

}

Manifest

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

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />
    <permission
    android:name="my package.permission.MAPS_RECEIVE"
    android:protectionLevel="signature"/>
  <uses-permission android:name="my package.permission.MAPS_RECEIVE"/>
  <!-- Copied from Google Maps Library/AndroidManifest.xml. -->
  <uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="16"/>
  <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"/>
  <!-- External storage for caching. -->
  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
  <!-- My Location -->
  <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
  <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
  <!-- Maps API needs OpenGL ES 2.0. -->
  <uses-feature
    android:glEsVersion="0x00020000"
    android:required="true"/>
  <!-- End of copy. -->
    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >

         <meta-data
      android:name="com.google.android.maps.v2.API_KEY"
      android:value="my key"/>

        <activity
            android:name="my package.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>

         <activity android:name=".main">
               </activity>

         <activity android:name=".mapPage">
              </activity>

         <activity android:name=".ThirdPartyWeb"
          android:theme="@android:style/Theme.Dialog">  

              </activity>

    </application>

</manifest>

The layout

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

  <fragment xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/map"
        android:layout_alignParentTop="true"
        android:layout_centerInParent="true"
        android:layout_height="250dp"
        android:layout_width="fill_parent"
  class="com.google.android.gms.maps.SupportMapFragment"/>

    <ImageView 
        android:layout_alignParentTop="true"
        android:layout_centerInParent="true"
        android:layout_height="50dp"
        android:layout_width="fill_parent"
        android:background="@color/darkGrey"/>

        <Button 
        android:layout_alignParentTop="true"
        android:layout_marginTop="10dp"
        android:layout_alignParentLeft="true"
        android:id="@+id/menuButton"
        android:background="@drawable/icon_menu"
        android:layout_height="30dp"
        android:layout_width="30dp"/>

         <Button 
        android:layout_alignParentTop="true"
        android:layout_marginTop="10dp"
        android:layout_toRightOf="@+id/menuButton"
        android:layout_marginLeft="20dp"
        android:id="@+id/"
        android:background="@drawable/icon_off"
        android:layout_height="35dp"
        android:layout_width="55dp"/>

       <EditText          
        android:layout_alignParentTop="true"
        android:layout_width="wrap_content"
        android:layout_marginTop="10dp"
        android:layout_toRightOf="@+id/"
        android:layout_marginLeft="20dp"
        android:layout_toEndOf="@+id/"
        android:id="@+id/seachBox"
        android:hint="@string/search"
        android:layout_height="35dp"
        android:layout_alignParentEnd="true"
        android:background="@color/white"/>

       <Button 
        android:layout_alignParentTop="true"
        android:layout_alignParentRight="true"
        android:layout_marginTop="10dp"
        android:id="@+id/searchButton"
        android:background="@drawable/graphic_search"
        android:layout_height="35dp"
        android:layout_width="20dp"/>

       <ImageView 
        android:layout_above="@+id/newsFeed"
        android:layout_centerInParent="true"
        android:layout_height="35dp"
        android:layout_width="fill_parent"
        android:background="@color/darkGrey"/>

       <TextView 
           android:layout_alignParentLeft="true"
           android:layout_height="wrap_content"
           android:layout_width="wrap_content"
           android:layout_above="@+id/newsFeed"
           android:layout_marginBottom="11dp"
           android:textColor="@color/white"
           android:text="@string/news_feed"
            android:textAppearance="?android:attr/textAppearanceSmall"/>

        <ListView 
           android:layout_alignParentBottom="true"
           android:id="@+id/newsFeed"
           android:layout_width="fill_parent"
           android:layout_height="wrap_content">"

       </ListView>



</RelativeLayout>

解决方案

Ok problem solved. On the google api console, there is two google map api v2's. I had the one just for google maps api v2 if you look just above it, it says google maps v2 android. I turned on that one as well and the map is running.

这篇关于谷歌地图API V2灰色屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆