【问题标题】:how can i import this packages (Libraries) in my android application com.google.android.gms.maps.GoogleMap我如何在我的 android 应用程序 com.google.android.gms.maps.GoogleMap 中导入这个包(库)
【发布时间】:2013-12-14 01:49:51
【问题描述】:

如何在我的 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 开普勒, 使用 SDK API Google API(Google Inc.)API 19 编译 最低 API 级别 14 已添加 Google APIs[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 新手,所以请大家帮帮我。 提前谢谢

【问题讨论】:

  • 你应该从这个问题中删除你的 APiKey

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


【解决方案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. 右键单击您的项目 -> 属性 -> 左侧的“Android”项 -> “添加...”一个库。

就像:

【讨论】:

  • 感谢该解决方案对我有用,我在工作区中添加了错误的 lib 项目。
【解决方案2】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-04-23
    • 2016-12-15
    • 1970-01-01
    • 2020-09-02
    • 2014-10-24
    • 2021-09-05
    • 1970-01-01
    • 2013-05-24
    相关资源
    最近更新 更多