【问题标题】:Google maps show only a brown screen and zoom谷歌地图只显示棕色屏幕和缩放
【发布时间】:2013-03-28 01:53:19
【问题描述】:

我想在我的安卓应用中显示谷歌地图应用:

我做了android开发者中提到的步骤:https://developers.google.com/maps/documentation/android/start

但是它在我的应用程序中为我显示,一个带有缩放(加号和减号按钮)的棕色屏幕,没有地图本身(它没有向我显示任何错误)

我创建了这个 xml 文件:

<?xml version="1.0" encoding="utf-8"?>


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



    <ImageView
        android:id="@+id/itemImage"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:src="@drawable/logo" />

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="400dp"
        android:layout_marginTop="10dp"
        android:layout_weight="66496.79"
        android:orientation="horizontal" >


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


    </RelativeLayout>

</LinearLayout>

这是我的清单文件:

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

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



    <uses-sdk
        android:minSdkVersion="1"
        android:targetSdkVersion="17" />
    <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.CAMERA"/>

    <permission
    android:name="com.example.sal.permission.MAPS_RECEIVE"
    android:protectionLevel="signature" />

    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
    <!-- The following two permissions are not required to use
     Google Maps Android API v2, but are recommended. -->
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
        <uses-permission android:name="com.example.sal.permission.MAPS_RECEIVE"/>
        <uses-permission android:name="android.permission.READ_PHONE_STATE"/>




    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" 
        android:name=".FriendPickerApplication">



        <activity
            android:name="com.example.sal.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>

         <!--  Entry for RegisterActivity.class -->
        <activity android:name=".RegisterActivity"
                  android:label="Register New Account"></activity>
        <meta-data android:value="@string/app_id" android:name="com.facebook.sdk.ApplicationId"/>
        <activity android:label="@string/app_name" android:name="com.facebook.LoginActivity"></activity>
        <activity android:name=".ProfileActivity" android:label="Profile page"></activity>

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


        <activity android:name="SaleMapActivity"></activity>
        <activity android:name="GroupMapActivity"></activity>
        <activity android:name="DeliverMapActivity"></activity>
        <activity android:name="PickFriendsActivity"></activity>
        <activity android:name="TabMainActivity"></activity>
        <activity android:name="itemSaleActivity"></activity>
        <activity android:name="FreindsActivity"></activity>
        <activity android:name="ExitActivity"></activity>
        <activity android:name="OneTimeDetailesScreen"></activity>
        <activity android:name="UpdateMapActivity"></activity>
        <activity android:name="DashBoardActivity"></activity>

    </application>

</manifest

>

【问题讨论】:

  • 你应用的包名是什么?是com.vogella.android.locationapi.maps吗?
  • 嗨,我把它改成了我的包名,但它仍然是同样的问题......
  • 您检查过您设备的日期/时间吗?这是对的吗?我知道这听起来很奇怪,但我在stackoverflow.com/questions/15615759/… 之前遇到过这个问题
  • 是的,设备时间日期正确
  • 我能知道你的包名是什么吗?您可以将更新的清单文件发布到问题中吗?谢谢

标签: java android


【解决方案1】:

改变这个:

<permission
    android:name="com.vogella.android.locationapi.maps.permission.MAPS_RECEIVE"
    android:protectionLevel="signature" />

到

<permission
    android:name="com.example.sal.permission.MAPS_RECEIVE"
    android:protectionLevel="signature" />

我不确定这是否会有所帮助,但这是我在上一个项目中使用的布局代码 (注意不同的片段类)

<fragment
    android:id="@+id/map_fragment"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    class="com.google.android.gms.maps.SupportMapFragment"
    map:mapType="normal"
            map:cameraTargetLat="@string/default_map_lat"
            map:cameraTargetLng="@string/default_map_lng"
            map:cameraZoom="8">
</fragment>

【讨论】:

  • 非常感谢,我会试试的,还有,我需要改变这条线吗? :
  • @AdirRahamim 不,你不需要。请确保将 MAPS_RECEIVE 的包名更改为您自己的包名,显然@Corey 不是将包名更改为example.sal 而是您自己的包名。
  • 这一行 似乎也有点奇怪。尝试将其更改为
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-05-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-06-25
  • 2013-06-02
相关资源
最近更新 更多