關於Android中使用MapActivity類的問題

來源:互聯網
上載者:User

最近在學Android,想做個google-map-api的小應用,哪知道費死勁了……

首先是關於<uses-library />的引用位置,書中沒有提及,結果程式一運行就出現has stopped unexpectedly錯誤,我一開始以為api給的key有問題,於是重新申請了一下,可是問題仍在,於是網上一頓狂搜,發現應該是這樣滴:    <application android:icon="@drawable/icon" android:label="@string/app_name">        <activity android:name=".HelloAndroid"                  android:label="@string/app_name">            <intent-filter>                <action android:name="android.intent.action.MAIN" />                <category android:name="android.intent.category.LAUNCHER" />            </intent-filter>        </activity>        <uses-library android:name="com.google.android.maps" />    </application>注意,這個<uses-library />標籤只在<application />標籤中才能添加,位置放不對,作為第三方庫,就不會被正確載入。改完這裡,繼續運行,仍然出現錯誤,還是has stopped unexpectedly,最後幾經實驗,終於把問題鎖定在了MapActivity這個類上,因為在如同往常一樣的繼承Activity類的時候,一切正常,GPS也能類比使用,但是如果一旦繼承了MapActivity就會出現上述錯誤了。突然想起了是不是在build的過程中,庫的問題,然後把屬性中,Android選項的Project build target選項從Android1.5改選為Google APIs類型,這時候,還得把按照書中作為第三方庫添加進入JAVA
build path的map.jar庫刪掉,因為選擇了這個之後,在Google APIs裡面自動帶了mar.jar庫。至此,再重新運行,就可以看到我折騰了好幾小時的google map了……燒香……
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.