作者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