[問題] google地圖無法在模擬器上顯示

看板AndroidDev作者 (囧rz)時間12年前 (2013/04/14 16:01), 編輯推噓2(2020)
留言22則, 5人參與, 最新討論串1/1
最近因為要用到google地圖,所以用debug keystore產生一組sha1到網路申請api key 我先開啟service中的google maps android api v2和google maps api v2後 然後在androidmanifest中寫入 <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> <uses-permission android:name="android.permission.INTERNET"/> 以及 <uses-library android:name="com.google.android.maps"/> 接著在layout部分我寫了 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <com.google.android.maps.MapView android:id="@+id/map" android:layout_width="match_parent" android:layout_height="match_parent" android:apiKey="(我的api key)" /> </LinearLayout> 最後就是在main中把繼承自activity改成繼承自MapActivity然後實作 isRouteDisplayed這個方法(不過實際上我只是把它放進來沒更改它) 但是在run的時候locat給我的訊息是"couldn't get connection factory client 而且在layout部分則出現 ”Missing styles. Is the correct theme chosen for this layout? Use the Theme combo box above the layout to choose a different layout, or fix the theme style references Failed to find style 'mapViewStyle' in current theme“這樣的訊息 結果就是在模擬器中只跑出灰色格子,地圖沒辦法顯示出來。因為用了一整天 上網找的答案都沒辦法解決所以想問一下板上有人也有遇到這樣問題過嗎? 還是我有少漏掉什麼部分沒做的呢? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 118.168.217.208

04/14 17:39, , 1F
先問一下如果你是用模擬器,那你的模擬器用對嗎? 不一樣喔
04/14 17:39, 1F

04/14 18:57, , 2F
我專案版本和模擬器都是用google api的
04/14 18:57, 2F

04/14 19:53, , 3F
新版的 Google Maps API 要在有 Google Play Service 的
04/14 19:53, 3F

04/14 19:54, , 4F
機器才能跑,模擬器沒有 Google Play Service 無法跑
04/14 19:54, 4F

04/14 19:55, , 5F
雖然有一些方法可以讓模擬器上也能動,不過我覺得直接拿
04/14 19:55, 5F

04/14 19:55, , 6F
實機還是比較方便
04/14 19:55, 6F

04/14 19:57, , 7F

04/14 22:11, , 8F
哇咧 這我就要跟人借手機用了~~
04/14 22:11, 8F

04/14 22:54, , 9F
但我剛看模擬器自己裡面的google map卻可以用耶
04/14 22:54, 9F
剛剛逛google時候看到這一篇http://ppt.cc/A7aL 他的方法跟我設定的不太一樣 不曉得有沒有人試過可以分享一下有沒有成功 ※ 編輯: fortooth 來自: 118.168.217.208 (04/15 01:35)

04/15 07:42, , 10F
開map的時候有log嗎?不一定是error的
04/15 07:42, 10F

04/15 09:05, , 11F
模擬器很確定可以開google map(看的到地圖)
04/15 09:05, 11F

04/15 09:09, , 12F
模擬器可以開 Google Maps 但用新版 Google Maps API 應
04/15 09:09, 12F

04/15 09:09, , 13F
該會看到要裝 Google Play Service 那個畫面
04/15 09:09, 13F

04/15 09:10, , 14F
(我附的連結裡有圖)
04/15 09:10, 14F

04/15 14:16, , 15F
我沒有跑出來耶 我的畫面就是google地圖的背景圖而已
04/15 14:16, 15F

04/16 12:12, , 16F
xml 試試 fragment 我改成這樣就好了
04/16 12:12, 16F

04/16 15:58, , 17F
我改成fragment 加上google play service lib之後 他跑出
04/16 15:58, 17F

04/16 15:59, , 18F
this app won't run unless you update google play
04/16 15:59, 18F

04/16 15:59, , 19F
service
04/16 15:59, 19F

04/18 00:41, , 20F
你成功了
04/18 00:41, 20F

04/21 17:22, , 21F
我最後還是跑不出來耶 剛剛查了一下好像現在沒辦法在模
04/21 17:22, 21F

04/21 17:23, , 22F
擬器上跑 只能跑在手機上
04/21 17:23, 22F
文章代碼(AID): #1HQc9DL2 (AndroidDev)