2013-11-28 13 views
0

如何才能在我的Android應用程序導入該包(庫)如何導入這個包(庫)在我的Android應用程序com.google.android.gms.maps.GoogleMap

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谷歌API(谷歌公司)API 19 最低API等級14 已經加入谷歌的API [安卓[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" /> 

,並添加MapAPI重點從https://code.google.com/apis/console 獲取和添加到我的佈局文件遵循

<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" /> 

我只得到我的模擬器作爲輸出和控制檯網格顯示此錯誤 4月11日至28日:04:57.535:E/MapActivity(1555):無法獲得連接到ction廠客戶

我無法理解這樣的錯誤「怎麼我在Android的,所以請人新的全部意義幫我在這裏。 thankx提前

+0

你應該從這個問題 – gian1200

回答

0

我認爲問題是,你還沒有導入/包括/安裝的谷歌Play服務庫。 This link將爲您提供要遵循的步驟去實現它。下一步你也應該檢查this page。這是在您的項目中包含Google地圖的更新文檔。你已經完成了其中一些,但你似乎也錯過了一些東西。

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」的左側項目 - >「添加...」一庫。

就像: enter image description here

+0

刪除您APiKey thankx該解決方案是爲我工作,我在我的工作區中添加錯誤的lib項目。 –

相關問題