2010-01-15 21 views
0

我想學習一些我的android手機的編程。 我成功地做了你好世界的應用程序。 現在我想嘗試的MapView在這裏找到:http://developer.android.com/resources/tutorials/views/hello-mapview.html谷歌地圖視圖運行時出錯 - Droid

我的代碼如下:

package com.example.hellomapview; 

import android.os.Bundle; 
import android.widget.LinearLayout; 
import android.widget.ZoomControls; 
import com.google.android.maps.*; 


public class HelloMapView extends MapActivity { 
    /** Called when the activity is first created. */ 
LinearLayout linearLayout; 
MapView mapView; 
ZoomControls mZoom; 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     linearLayout = (LinearLayout) findViewById(R.id.zoomview); 
     mapView = (MapView) findViewById(R.id.mapview); 
     mZoom = (ZoomControls) mapView.getZoomControls(); 
     linearLayout.addView(mZoom); 
     setContentView(R.layout.main); 
    } 
    protected boolean isRouteDisplayed() { return false;} 
} 

我使用Eclipse和我有SDK和AVD全部安裝正確,但只要我做一個運行>在Eclipse中運行它開始了與OK:

[2010-01-15 12:27:03 - HelloMapView]New emulator found: emulator-5554 
[2010-01-15 12:27:03 - HelloMapView]Waiting for HOME ('android.process.acore') to be launched... 
[2010-01-15 12:27:46 - HelloMapView]HOME is up on device 'emulator-5554' 
[2010-01-15 12:27:46 - HelloMapView]Uploading HelloMapView.apk onto device 'emulator-5554' 
[2010-01-15 12:27:46 - HelloMapView]Installing HelloMapView.apk... 

The emulator comes up and I see my droid phone ready to load the HelloMapView app..but then it dies with the following: 

[2010-01-15 12:27:51 - HelloMapView]Installation error: INSTALL_FAILED_MISSING_SHARED_LIBRARY 
[2010-01-15 12:27:51 - HelloMapView]Please check logcat output for more details. 
[2010-01-15 12:27:52 - HelloMapView]Launch canceled! 

我從來沒有做過任何Android式發展和我來自一個C#背景,使我的Java是前途未卜......但沒有人看到任何我可能會失蹤?

+1

該系統被稱爲* Android *。 * Droid *是摩托羅拉手機。 – 2010-01-15 17:38:49

+0

對,但我的手機機器人正在運行系統android ...我在哪裏出錯了? – JonH 2010-01-15 17:42:07

+1

我的意思是標籤:使用'android'而不是'droid'。 – 2010-01-15 17:50:50

回答

3

我的猜測是您已經創建了一個不包含Google API的模擬器。

如果您啓動tools/android,您會看到可用的包中有例如「SDK平臺Android 1.5,API 3」和「Google API Android API 3」。

如果您想使用地圖,則需要安裝Google APIs包,並在創建虛擬設備時使用該包。

+0

好吧,我現在已經安裝了google APIS android api 3 rev 3。我在執行run-> run時遇到的新錯誤是「HelloMapView]找不到HelloMapView.apk」。 – JonH 2010-01-15 18:20:37