Android Google地图无法显示

时间:2010-09-30 17:16:09

标签: android google-maps

我知道之前已经问过并回答了这个问题,但是在完成所有说明之后,我仍然遇到同样的问题:我的Android应用程序中有一个MapView,但视图只显示底层网格(和叠加层) ),但不是地图本身。

我正在Eclipse中构建项目,如果这有所不同。

我有以下AndroidManifest.xml文件:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.myapplication"
      android:versionCode="1"
      android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
    <activity android:name=".MyApplication"
              android:label="@string/app_name" android:theme="@android:style/Theme.NoTitleBar">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
 <uses-library android:name="com.google.android.maps"></uses-library>

      

然后在我的shell中,我运行了以下命令: $ keytool -list -alias androiddebugkey -keystore ~/.android/debug.keystore -storepass android -keypass android

并获得以下输出: androiddebugkey, Sep 23, 2010, PrivateKeyEntry, Certificate fingerprint (MD5): DF:69:80:83:16:1A:F0:E9:B9:07:B9:BD:F7:BC:DB:61

我转到http://code.google.com/android/maps-api-signup.html并将值DF:69:80:83:16:1A:F0:E9:B9:07:B9:BD:F7:BC:DB:61插入到表单中,并获得以下API密钥:0peT6kQ21Tpd1Rs61gBHHtquJwDcNeKkqedT08g

我的res / layout / main.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:apiKey="0peT6kQ21Tpd1Rs61gBHHtquJwDcNeKkqedT08g" />

我的MyApplication.java文件如下所示:     package com.example.myapplication;

import android.os.Bundle;

import com.google.android.maps.MapActivity;

public class MyApplication extends MapActivity {

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

    @Override protected boolean isRouteDisplayed( ) {
        return false;
    }
}

我使用Eclipse部署了项目,而我的AVD与Google API 2.1-update1兼容。我检查以确保项目已签名,命令$ jarsigner -verify -verbose ~/workspace/MyApplication/bin/MyApplication.apk返回以下输出:

sm      2200 Thu Sep 30 12:42:16 EDT 2010 res/drawable/icon.png
sm       676 Thu Sep 30 12:42:16 EDT 2010 res/layout/main.xml
sm      1796 Thu Sep 30 12:42:16 EDT 2010 AndroidManifest.xml
sm      1968 Thu Sep 30 12:42:16 EDT 2010 resources.arsc
sm      7816 Thu Sep 30 12:42:16 EDT 2010 classes.dex
         646 Thu Sep 30 12:42:16 EDT 2010 META-INF/MANIFEST.MF
         699 Thu Sep 30 12:42:16 EDT 2010 META-INF/CERT.SF
         776 Thu Sep 30 12:42:16 EDT 2010 META-INF/CERT.RSA

  s = signature was verified 
  m = entry is listed in manifest
  k = at least one certificate was found in keystore
  i = at least one certificate was found in identity scope

我已经在AVD上给了应用程序大约十分钟来加载地图图像而我什么都没得到。 adb logcat未报告任何例外情况:

I/ActivityManager(   56): Starting activity: Intent { cmp=com.example.myapplication/.MyApplication }
E/ActivityThread(  259): Failed to find provider info for com.google.settings
E/ActivityThread(  259): Failed to find provider info for com.google.settings
W/MapActivity(  259): Recycling dispatcher com.google.googlenav.datarequest.DataRequestDispatcher@43d1e3b8
V/MapActivity(  259): Recycling map object.
I/ActivityManager(   56): Displayed activity com.example.myapplication/.MyApplication: 376 ms (total 376 ms)

任何人都可以弄明白我在做错了什么吗?任何意见,将不胜感激。感谢。

4 个答案:

答案 0 :(得分:4)

向清单添加互联网权限...

<uses-permission android:name="android.permission.INTERNET" />

答案 1 :(得分:0)

我关闭了模拟器并重新启动它,现在它工作正常。我注意到新的模拟器有“3G”符号,显示电话接收的图标有两个条。 (旧模拟器没有3G或1G符号,也没有任何条形码。)也许这有所不同......?

答案 2 :(得分:0)

首先,检查您是否可以从模拟器访问互联网。 尝试启动浏览器或谷歌地图并进行一些搜索。

如果它不起作用,请检查以下链接以获取模拟器的互联网访问权限。

http://justkumar.blogspot.com/2011/09/how-to-access-pcs-internet-from-android.html

答案 3 :(得分:0)

在应用标记中的android manifest.xml文件中添加以下标记,即

<uses-permission android:name="android.permission.INTERNET" />
    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >

        <uses-library android:name="com.google.android.maps" />  
            Your activity......
    </application>

另外,使用自定义调试密钥库。转到窗口选择首选项,然后在android下选择build。