作者fortooth (囧rz)
看板AndroidDev
標題[問題] google地圖無法在模擬器上顯示
時間Sun Apr 14 16:01:15 2013
最近因為要用到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
1F:→ Jyie:先問一下如果你是用模擬器,那你的模擬器用對嗎? 不一樣喔 04/14 17:39
2F:→ fortooth:我專案版本和模擬器都是用google api的 04/14 18:57
3F:→ dreamcwli:新版的 Google Maps API 要在有 Google Play Service 的 04/14 19:53
4F:→ dreamcwli:機器才能跑,模擬器沒有 Google Play Service 無法跑 04/14 19:54
5F:→ dreamcwli:雖然有一些方法可以讓模擬器上也能動,不過我覺得直接拿 04/14 19:55
6F:→ dreamcwli:實機還是比較方便 04/14 19:55
8F:→ fortooth:哇咧 這我就要跟人借手機用了~~ 04/14 22:11
9F:→ fortooth:但我剛看模擬器自己裡面的google map卻可以用耶 04/14 22:54
剛剛逛google時候看到這一篇
http://ppt.cc/A7aL
他的方法跟我設定的不太一樣
不曉得有沒有人試過可以分享一下有沒有成功
※ 編輯: fortooth 來自: 118.168.217.208 (04/15 01:35)
10F:→ cooper6334:開map的時候有log嗎?不一定是error的 04/15 07:42
11F:→ Jyie:模擬器很確定可以開google map(看的到地圖) 04/15 09:05
12F:→ dreamcwli:模擬器可以開 Google Maps 但用新版 Google Maps API 應 04/15 09:09
13F:→ dreamcwli:該會看到要裝 Google Play Service 那個畫面 04/15 09:09
14F:→ dreamcwli:(我附的連結裡有圖) 04/15 09:10
15F:→ fortooth:我沒有跑出來耶 我的畫面就是google地圖的背景圖而已 04/15 14:16
16F:推 billywang:xml 試試 fragment 我改成這樣就好了 04/16 12:12
17F:→ fortooth:我改成fragment 加上google play service lib之後 他跑出 04/16 15:58
18F:→ fortooth:this app won't run unless you update google play 04/16 15:59
19F:→ fortooth:service 04/16 15:59
20F:推 billywang:你成功了 04/18 00:41
21F:→ fortooth:我最後還是跑不出來耶 剛剛查了一下好像現在沒辦法在模 04/21 17:22
22F:→ fortooth:擬器上跑 只能跑在手機上 04/21 17:23