谷歌地图没有在Android设备上显示

时间:2012-12-11 22:55:20

标签: android google-maps

Android设备仅显示地图图块。似乎被广泛报道。我按照此链接的说明进行操作:

https://developers.google.com/maps/documentation/android/start

我做了以下事情:

1)在Eclipse中,我签署了发布模式。我选择文件>出口。选择导出Android应用程序,然后单击下一步。创建了一个新的密钥库。然后将apk上传到谷歌播放。

2)Android应用程序在设备上工作,但地图没有显示。它只显示了瓷砖。

3)所以我按照上面链接中的说明进行操作。

4)我找到了上面创建的密钥库文件。我的密钥库名为ziggy.keystore,别名为ziggy密钥库。

5)我在Mac OSX的终端上运行了这个:

keytool -list -v -keystore ziggy.keystore -alias ziggy\ keystroke

6)上面的命令产生的输出包括一行包含证书的SHA-1指纹。指纹是由冒号分隔的20个两位十六进制数字的序列。

7)现在我有了签名证书指纹,我在Google API控制台中为该应用程序创建了一个项目。在浏览器中,我导航到https://code.google.com/apis/console/

8)我点击了Create Project。我把它命名为API项目。我在主窗口中看到了API和服务列表。

9)我向下滚动,直到看到Google Maps Android API v2。在条目的右侧,我单击了开关指示器,使其处于打开状态。我同意服务条款并点击接受。

10)在左侧导航栏中,我点击了API Access。在结果页面中,我单击了Create New Android Key。在结果对话框中,我输入了SHA-1指纹,然后是分号,然后输入了应用程序的包名称。

11)我复制了API密钥。我打开了我的应用程序的清单,包含在AndroidManifest.xml文件中。并将以下元素添加为元素的子元素,方法是在结束标记之前插入:

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

*请注意,我使用了真正的api密钥。

12)我也加了这个:

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


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

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

13)然后在我的ShowMapActivity.java中:

    super.onCreate(savedInstanceState);
    setContentView(R.layout.show_map);
            mapView = (MapView) findViewById(R.id.mapview);

    myMapController = mapView.getController();  
    mapView.setBuiltInZoomControls(true);

    Drawable marker=getResources().getDrawable(android.R.drawable.star_big_on);
            ...

14)然后在我的show_map.xml文件中:

<com.google.android.maps.MapView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/mapview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:clickable="true"
    android:state_enabled="true" 
    android:apiKey="my_api_key"
/>

*我用真钥替换了my_api_key。

所以我按照所有说明操作,然后当我在Android设备上下载应用程序时,它没有显示地图。它只是显示了瓷砖的东西,之前已有报道。

我不确定我错过了哪一步才能让它发挥作用。

2 个答案:

答案 0 :(得分:1)

配置步骤对我来说很好。

但我认为你是以老式的方式与图书馆进行互动。我知道文档说可以添加和控制MapView到活动,但我会尝试使用新的GoogleMapMapFragment方法。我不确定支持“扩展MapActivity和处理MapView”是否在库的V2上

以下是它的文档:https://developers.google.com/maps/documentation/android/map#add_a_map_to_an_android_application

你试过吗?

答案 1 :(得分:0)

感谢您的详细描述。问题是您使用的是针对Android v2 API的设置过程f,而是来自v1 API的类。由于v1现已弃用,因此强烈建议您使用v2。如果您按照关于使用Google Play服务构建的其他说明,您应该没问题。

相关问题