2010-09-30 92 views
1

我知道这个问题之前已经被问及回答,但在按照所有说明操作之后,我仍然遇到同样的问题:我的Android应用程序中有一个MapView,但视图仅显示底层网格(和覆盖),但不是地图本身。Android谷歌地图不显示

我在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> 

然后在我的壳,我跑以下命令: $ 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 /布局/ 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文件看起来像: 包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与谷歌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的应用大约有10分钟时间来加载地图图像和我没有变任何东西。该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 [email protected] 
V/MapActivity( 259): Recycling map object. 
I/ActivityManager( 56): Displayed activity com.example.myapplication/.MyApplication: 376 ms (total 376 ms) 

任何人都可以找出我在做什么错在这里?任何意见,将不胜感激。谢谢。

+0

您是否使用Google API版本运行模拟器,而不是正常版本?你的模拟器有互联网连接吗?谷歌地图应用程序的工作? – Falmarri 2010-09-30 17:26:20

+0

是的,这是Google API,而不是普通版本。我不确定如何测试AVD的互联网连接。但我看了一下地图应用程序 - 一些地图被加载。如果我滚动浏览地图,我会看到地图,但是如果我向上,向下,向左或向右滚动得太远,我只能看到下面的网格(它不会加载地图的其余部分)。 – jay 2010-09-30 17:42:40

回答

0

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

+0

是的,这是有所作为。当模拟器启动时,它会尝试确定当时是否有Internet连接。如果你这样做,它的行为正常,你有3G图标和2条信号。但是,如果仿真器没有检测到互联网连接,它将表现得好像根本没有连接(数据或语音),您将得到0条信号。即使您清除了主机上的任何Internet问题,这种情况也会持续存在。重新启动模拟器是我所知道的唯一解决方案。在0酒吧状态下,互联网接入将不起作用。 – CommonsWare 2010-09-30 19:15:27

+0

以我的经验,这是一个模拟器的错误。我一直都在上网,但模拟器似乎想要不时上网而不需要互联网。重新启动它可以修复它。 – ShadowGod 2010-10-01 07:32:56

4

添加Internet权限清单...

所有的
<uses-permission android:name="android.permission.INTERNET" /> 
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下选择生成。