如何在我的Android应用程序com.google.android.gms.maps.GoogleMap中导入此包(库)

时间:2013-11-28 15:02:40

标签: android google-maps google-maps-android-api-2

如何在我的Android应用程序中导入此包(库)

com.google.android.gms.maps.GoogleMap;

当我在我的应用程序中添加它时,它将显示为错误

但此导入成功

import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import android.os.Bundle;
import android.view.Menu;

我用过Eclipse kepler, 使用SDK API Google API(Google Inc.)API编译 最低API等级14 已添加Google API [Android [4.4] maps.jar 我使用谷歌地图Android APIv2 在清单文件中声明所有权限如下

<uses-sdk
        android:minSdkVersion="14"
        android:targetSdkVersion="19" />

    <permission
     android:name="com.example.googlenewmap.permission.MAPS_RECEIVE"/>

    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission
        android:name =  "com.google.android.providers.gsf.permission.READ_GSERVICES"/>
    <uses-permission android:name="com.example.googlenewmap.permission.MAPS_RECEIVE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

并从https://code.google.com/apis/console添加MapAPI密钥获取 并添加到我的布局文件中,如下所示

<com.google.android.maps.MapView
    android:id="@+id/mapView"
    android:layout_width="match_parent
    android:layout_height="match_parent"
    android:clickable="true"
    android:enabled="true"
    android:apiKey = "I have My APIKey here" />

我在模拟器中只获得了网格,因为输出和控制台显示此错误 11-28 04:04:57.535:E / MapActivity(1555):无法获得连接工厂客户端

我无法理解这个错误的全部含义'因为我是新的android所以请各位帮帮我。 谢谢你提前

2 个答案:

答案 0 :(得分:1)

关于你的描述

  

导入com.google.android.maps.MapActivity;
  导入com.google.android.maps.MapView;

这不在正确的轨道上,应该是

  

导入com.google.android.gms.maps.MapView;
  导入com.google.android.gms.maps.MapFragment;

  1. 确保已将项目“google-play-serviceslib”导入Eclipse。
  2. 右键单击您的项目 - &gt;属性 - &gt;左侧的“Android”项目 - &gt; “添加......”一个图书馆。
  3. 就像: enter image description here

答案 1 :(得分:0)

我认为问题在于您没有导入/包含/设置Google Play服务库。 This link将为您提供实现目标的步骤。下一步您还应该检查this page。这是在您的项目中包含Google地图的更新文档。你已经做了一些,但似乎你也错过了一些东西。