2010-07-21 65 views
1

我剛開始學習android的開發。安卓地圖視圖崩潰應用程序

我設置了一個測試應用程序,其中包含一個基本的文本視圖,當您點擊它時會更改文本。這工作得很好。所以我決定我想用mapview來做一些有趣的谷歌地圖。

我按照文檔中的說明,環顧了demomaps演示應用程序,但是當我在AVD中啓動我的應用程序(指向正確的源代碼,google API lvl3)時,我得到「應用程序已停止不料請重試」,當我在調試模式下啓動,我得到的唯一錯誤是‘源未找到’

下面是我的代碼的一些摘錄:

意見

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    > 
    <com.google.android.maps.MapView 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:enabled="true" 
     android:clickable="true" 
     android:apiKey="[ommitted for safety - i have an apikey though]" 
     /> 
</LinearLayout> 

清單

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
     package="leblanc.test.HelloCora" 
     android:versionCode="1" 
     android:versionName="1.0"> 
    <application android:icon="@drawable/icon" android:label="@string/app_name"> 

     <activity android:name=".hello" 
        android:label="@string/app_name"> 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 
       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity> 

    </application> 
    <uses-sdk android:minSdkVersion="3" /> 
    <uses-library android:name="com.google.android.maps" /> 
</manifest> 

我的消息來源的.java基本上是默認

我使用的是ADT在Eclipse中開發,在Linux機器上

讓我知道如果你需要

感謝任何其他信息!

編輯:關於我得到的錯誤的更多信息。

TestApp [Android Application] 
    DalvikVM [localhost:8619] 
    Thread [ <3> Main ] (Suspended (exception RuntimeException)) 
     ActivityThread.performLaunchActivity(ActivityThread$ActivityRecord) line: 2268 
     ActivityThread.handleLaunchActivity(ActivityThread$ActivityRecord) line: 2284  
     ActivityThread.access$1800(ActivityThread, ActivityThread$ActivityRecord) line: 112 
     ActivityThread$H.handleMessage(Message) line: 1692 
     ActivityThread$H(Handler).dispatchMessage(Message) line: 99 
     Looper.loop() line: 123 
     ActivityThread.main(String[]) line: 3948 
     Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method] 
     Method.invoke(Object, Object...) line: 521 
     ZygoteInit$MethodAndArgsCaller.run() line: 782 
     ZygoteInit.main(String[]) line: 540 
     NativeStart.main(String[]) line: not available [native method] 

而且,有趣的是,在Android SDK的demomaps演示應用程序不會崩潰(儘管地圖數據永遠不會加載,即使它具有互聯網訪問權限)

回答

1

我覺得有問題在「從網絡訪問地圖(谷歌地圖)」。

對於訪問網頁,我們必須添加"INTERNET PERMISSION" in AndroidMenifest.xml文件。

因此在</application>標記下面添加以下行。

<uses-permission android:name="android.permission.INTERNET"></uses-permission> 
+0

我補充說,到我的清單文件,但仍然有同樣的錯誤。奇怪的是android SDK中提供的mapsdemo項目不會崩潰。 – Andrew 2010-07-21 17:20:34

2

有一個錯誤在你的清單文件,下面的代碼應該是在應用程序代碼,而不是

<uses-library android:name="com.google.android.maps" /> 

這樣的變化之後會

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
     package="leblanc.test.HelloCora" 
     android:versionCode="1" 
     android:versionName="1.0"> 
    <application android:icon="@drawable/icon" android:label="@string/app_name"> 
     <uses-library android:name="com.google.android.maps" /> 
     <activity android:name=".hello" 
        android:label="@string/app_name"> 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 
       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity> 

    </application> 
    <uses-sdk android:minSdkVersion="3" /> 

</manifest>