如何使用谷歌地图API V2与API 10级? [英] How to use Google Maps API v2 with API level 10?

查看:110
本文介绍了如何使用谷歌地图API V2与API 10级?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据 1 中的code贴有可用于Android的API 12或更高版本。我试过code模拟器上具有API级别10(谷歌API平台2.3.3),我得到了以下著名的错误:

According to 1 the code posted there can be used for Android API 12 or later. I tried the code on an emulator having API level 10 (Google API platform 2.3.3) and I get the following famous error:

E / AndroidRuntime(429):java.lang.RuntimeException的:无法启动的活动ComponentInfo {com.example .... / com.example .... MainActivity}:android.view。 InflateException:二进制XML文件中的行#7:错误充气类片段

我复制粘贴下面我.xml文件。

I copy-paste my .xml file below.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/map"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  class="com.google.android.gms.maps.MapFragment"/>

所以,我认为是不支持的片段元素......(?)。我想同样的code与API级17的仿真器和我得到的消息(这是我读是目前仿真器的问题):

So I assume the fragment element is not supported...(?). I tried the same code in an emulator with API level 17 and I get that message (which as I am reading is currently an issue of the emulator):

This app won't run unless you update Google Play Services.

我没有有17级进行测试真实的设备,但我认为它可能工作。

I do not have a real device having level 17 to test it, but I assume that it might work.

我是否在上面code专为10级别的任何错误呢?什么是目前谷歌的支持,为了发展地图,Android设备与API级别10?

Do I have any mistake in the above code specifically for level 10? What is the code currently supported by Google, in order to develop maps in an android device with API level 10?

1 https://developers.google.com/maps/documentation/android/start

更新: 改变后 FragmentActivity SupportMapFragment 我得到了以下内容:

UPDATE: After changing to FragmentActivity and SupportMapFragment I get the following:

W / dalvikvm(6718):无法解析的Lmaps / A /杜超; (406)
W / dalvikvm(6718):类的链接Lmaps / A /杜;失败
W / dalvikvm(6718):无法解析Lmaps / A / EJ的父类; (2358)
W / dalvikvm(6718):类的链接Lmaps / A / EJ;失败
W / dalvikvm(6718):无法解析Lmaps / J / K的父类; (2374)
W / dalvikvm(6718):类的链接Lmaps / J / K;'失败
E / dalvikvm(6718):找不到类的maps.j.k,从地图的方法引用。 y.ae.a
W / dalvikvm(6718):VFY:无法解析新的实例3566(Lmaps / J / K;)在工业吊灯 S / Y / AE;
D / dalvikvm(6718):VFY:在0x007d更换运code输入0x22
D / dalvikvm(6718):VFY:死code 0X007F-008F的Lmaps/y/ae;.a(Landroid/view/LayoutInflater;Lcom/google/android/gms/maps/GoogleMapOptions;Z)Lmaps/y/ae;

W/dalvikvm( 6718): Unable to resolve superclass of Lmaps/a/du; (406)
W/dalvikvm( 6718): Link of class 'Lmaps/a/du;' failed
W/dalvikvm( 6718): Unable to resolve superclass of Lmaps/a/ej; (2358)
W/dalvikvm( 6718): Link of class 'Lmaps/a/ej;' failed
W/dalvikvm( 6718): Unable to resolve superclass of Lmaps/j/k; (2374)
W/dalvikvm( 6718): Link of class 'Lmaps/j/k;' failed
E/dalvikvm( 6718): Could not find class 'maps.j.k', referenced from method maps. y.ae.a
W/dalvikvm( 6718): VFY: unable to resolve new-instance 3566 (Lmaps/j/k;) in Lmap s/y/ae;
D/dalvikvm( 6718): VFY: replacing opcode 0x22 at 0x007d
D/dalvikvm( 6718): VFY: dead code 0x007f-008f in Lmaps/y/ae;.a(Landroid/view/LayoutInflater;Lcom/google/android/gms/maps/GoogleMapOptions;Z)Lmaps/y/ae;

和2秒后:
谷歌地图Android的API授权失败

And after 2 seconds:
Google Maps Android API Authorization failure

更新2: 我改变了项目建设目标为Android 10(我有它为Android 4.2)。所以,现在我没有看到授权失败)。我还粘贴谷歌我的API访问

UPDATE 2: I changed the project to build target for android 10 (I had it for android 4.2). So now I do not see the authorization failure). I also paste my api accesses from google .

我没有在我的项目IE中:
的.properties ProGuard的启用 #为ProGuard的萎缩,混淆你的code,取消本(可用的属性:sdk.dir,的user.home): <$c$c>#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

I do not have proguard enabled in my .properties of the project i.e.,:
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

#项目的目标。
目标=机器人-10
<$c$c>android.library.reference.1=../../adt-bundle-windows-x86/sdk/extras/google/google_play_services/libproject/google-play-services_lib

# Project target.
target=android-10
android.library.reference.1=../../adt-bundle-windows-x86/sdk/extras/google/google_play_services/libproject/google-play-services_lib

问题仍然存在:

九月1号至12号:57:36.306:D / dalvikvm(9072):DexOpt:找不到领域Landroid /内容/ RES /配置; .smallestScreenWidthDp < BR> 9月1日至12日:57:36.306:W / dalvikvm(9072):VFY:无法解析实例字段24
9月1日至12日:57:36.306:D / dalvikvm(9072):VFY:更换运code 0×52,在×0012
9月1日至12日:57:36.306:D / dalvikvm(9072):VFY:在LCOM /谷歌/安卓/ GMS /普通/ GooglePlayServicesUtil死code 0x0014-0018; .B(Landroid /内容/ RES /资源;)z
9月1日至12日:57:36.326:W / dalvikvm(1914年):disableGcForExternalAlloc:假
9月1日至12日:57:36.446:D / dalvikvm(9072):GC_CONCURRENT释放186K,45%免费3135K / 5639K,外部0K / 0K,暂停3毫秒+ 2ms的 < BR> 9月1日至12日:57:36.476:W / dalvikvm(9072):无法解析的Lmaps / A /杜超; (406)
9月1日至12日:57:36.476:W /的ResourceType(7905):getEntry失败,因为entryIndex 303超出类型entryCount 133
9月1日至12日:57:36.476:W /的ResourceType(7905):如果没有获得对0x7f02012f条目(T = 1 E = 303)封装0(错误-2147483647)
9月1日至12日:57:36.476:W /的ResourceType(7905):getEntry失败,因为entryIndex 827超出类型entryCount 133
9月1日至12日:57:36.476:W / dalvikvm(9072):类的链接Lmaps / A /杜;失败
9月1日至12日:57:36.476:W / dalvikvm(9072):无法解析Lmaps / A / EJ的父类; (2358)
9月1日至12日:57:36.476:W / dalvikvm(9072):类的链接Lmaps / A / EJ;失败
9月1日至12日:57:36.476:W / dalvikvm(9072):无法解析Lmaps / J / K的父类; (2374)
9月1日至12日:57:36.476:W / dalvikvm(9072):类的链接Lmaps / J / K;'失败
9月1日至12日:57:36.486:E / dalvikvm(9072):找不到类的maps.j.k,从法maps.y.ae.a引用
9月1日至12日:57:36.486:W / dalvikvm(9072):VFY:无法解析新的实例3566(Lmaps / J / K;)在Lmaps / Y / AE;
9月1日至12日:57:36.486:D / dalvikvm(9072):VFY:在0x007d更换运code输入0x22
9月1日至12日:57:36.496:D / dalvikvm(9072):VFY:死code 0X007F-008F在Lmaps / Y / AE; .A(Landroid /查看/ LayoutInflater; LCOM /谷歌/安卓/ GMS /地图/ GoogleMapOptions; Z)Lmaps / Y / AE;
9月1日至12日:57:36.546:I /密钥库(1270):UID:1000动作:电子 - &GT; 7状态:3 - &GT; 3重试:4
9月1日至12日:57:36.556:I /密钥库(1270):UID:1000动作:电子 - &GT; 7状态:3 - &GT; 3重试:4
&LT;九月一号至12日:57:36.576:W /的ResourceType(7905):如果没有获得对0x7f02033b条目(T = 1 E = 827)封装0(错误-2147483647)
9月1日至12日:57:36.576:V /窗口管理器(1369):在AppWindowToken完成的动画{410a0930记号= HistoryRecord {4099f2f0 com.example ... / MainActivity}} @ 20019326
9月1日至12日:57:36.596:W /的ResourceType(7905):getEntry失败,因为entryIndex 303超出类型entryCount 133
9月1日至12日:57:36.616:W /的ResourceType(7905):如果没有获得对0x7f02012f条目(T = 1 E = 303)封装0(错误-2147483647)
9月1日至12日:57:36.616:W /的ResourceType(7905):getEntry失败,因为entryIndex 827超出类型entryCount 133
9月1日至12日:57:36.616:W /的ResourceType(7905):如果没有获得对0x7f02033b条目(T = 1 E = 827)封装0(错误-2147483647)
9月1日至12日:57:36.686:D / dalvikvm(9072):GC_CONCURRENT释放276K,45%免费3257K / 5895K,外部0K / 0K,暂停4毫秒+ 9ms的 < BR> 9月1日至12日:57:36.876:I /密钥库(1270):UID:1000动作:电子 - &GT; 7状态:3 - &GT; 3重试:4
9月1日至12日:57:37.026:D / ATRecorder(9072):com.htc.autotest.dlib.RecordEngine装载机dalvik.system.DexClassLoader@405d2328
9月1日至12日:57:37.046:D / WindowManagerImpl(9072):addView,新观点,mViews [0]:com.android.internal.policy.impl.PhoneWindow$DecorView@405220f0
9月1日至12日:57:37.056:I /密钥库(1270):UID:1000动作:电子 - &GT; 7状态:3 - &GT; 3重试:4
9月1日至12日:57:37.117:D / PhoneApp(1491):EVENT_QUERY_MO_PACKAGES
9月1日至12日:57:37.137:D / libEGL(9072):加载/system/lib/egl/libGLES_android.so
9月1日至12日:57:37.147:D / WindowManagerImpl(1369):finishRemoveViewLocked,mViews [1]:com.android.internal.policy.impl.PhoneWindow$DecorView@40957078
9月1日至12日:57:37.147:I / ActivityManager(1369):显示com.example ... / MainActivity:+ 931ms
9月1日至12日:57:37.147:W / SchedPolicy(9072):add_tid_to_cgroup没有写''(参数无效);背景= 0
9月1日至12日:57:37.157:D / libEGL(9072):加载/system/lib/egl/libEGL_adreno200.so
9月1日至12日:57:37.157:W / InputManagerService(1369):[unbindCurrentClientLocked]关闭输入法客户端
9月1日至12日:57:37.157:W / InputManagerService(1369):[startInputLocked]启用输入法客户端
9月1日至12日:57:37.187:D / libEGL(9072):加载/system/lib/egl/libGLESv1_CM_adreno200.so

01-12 09:57:36.306: D/dalvikvm(9072): DexOpt: couldn't find field Landroid/content/res/Configuration;.smallestScreenWidthDp
01-12 09:57:36.306: W/dalvikvm(9072): VFY: unable to resolve instance field 24
01-12 09:57:36.306: D/dalvikvm(9072): VFY: replacing opcode 0x52 at 0x0012
01-12 09:57:36.306: D/dalvikvm(9072): VFY: dead code 0x0014-0018 in Lcom/google/android/gms/common/GooglePlayServicesUtil;.b (Landroid/content/res/Resources;)Z
01-12 09:57:36.326: W/dalvikvm(1914): disableGcForExternalAlloc: false
01-12 09:57:36.446: D/dalvikvm(9072): GC_CONCURRENT freed 186K, 45% free 3135K/5639K, external 0K/0K, paused 3ms+2ms
01-12 09:57:36.476: W/dalvikvm(9072): Unable to resolve superclass of Lmaps/a/du; (406)
01-12 09:57:36.476: W/ResourceType(7905): getEntry failing because entryIndex 303 is beyond type entryCount 133
01-12 09:57:36.476: W/ResourceType(7905): Failure getting entry for 0x7f02012f (t=1 e=303) in package 0 (error -2147483647)
01-12 09:57:36.476: W/ResourceType(7905): getEntry failing because entryIndex 827 is beyond type entryCount 133
01-12 09:57:36.476: W/dalvikvm(9072): Link of class 'Lmaps/a/du;' failed
01-12 09:57:36.476: W/dalvikvm(9072): Unable to resolve superclass of Lmaps/a/ej; (2358)
01-12 09:57:36.476: W/dalvikvm(9072): Link of class 'Lmaps/a/ej;' failed
01-12 09:57:36.476: W/dalvikvm(9072): Unable to resolve superclass of Lmaps/j/k; (2374)
01-12 09:57:36.476: W/dalvikvm(9072): Link of class 'Lmaps/j/k;' failed
01-12 09:57:36.486: E/dalvikvm(9072): Could not find class 'maps.j.k', referenced from method maps.y.ae.a
01-12 09:57:36.486: W/dalvikvm(9072): VFY: unable to resolve new-instance 3566 (Lmaps/j/k;) in Lmaps/y/ae;
01-12 09:57:36.486: D/dalvikvm(9072): VFY: replacing opcode 0x22 at 0x007d
01-12 09:57:36.496: D/dalvikvm(9072): VFY: dead code 0x007f-008f in Lmaps/y/ae;.a (Landroid/view/LayoutInflater;Lcom/google/android/gms/maps/GoogleMapOptions;Z)Lmaps/y/ae;
01-12 09:57:36.546: I/keystore(1270): uid: 1000 action: e -> 7 state: 3 -> 3 retry: 4
01-12 09:57:36.556: I/keystore(1270): uid: 1000 action: e -> 7 state: 3 -> 3 retry: 4
<01-12 09:57:36.576: W/ResourceType(7905): Failure getting entry for 0x7f02033b (t=1 e=827) in package 0 (error -2147483647)
01-12 09:57:36.576: V/WindowManager(1369): Finished animation in AppWindowToken{410a0930 token=HistoryRecord{4099f2f0 com.example..../.MainActivity}} @ 20019326
01-12 09:57:36.596: W/ResourceType(7905): getEntry failing because entryIndex 303 is beyond type entryCount 133
01-12 09:57:36.616: W/ResourceType(7905): Failure getting entry for 0x7f02012f (t=1 e=303) in package 0 (error -2147483647)
01-12 09:57:36.616: W/ResourceType(7905): getEntry failing because entryIndex 827 is beyond type entryCount 133
01-12 09:57:36.616: W/ResourceType(7905): Failure getting entry for 0x7f02033b (t=1 e=827) in package 0 (error -2147483647)
01-12 09:57:36.686: D/dalvikvm(9072): GC_CONCURRENT freed 276K, 45% free 3257K/5895K, external 0K/0K, paused 4ms+9ms
01-12 09:57:36.876: I/keystore(1270): uid: 1000 action: e -> 7 state: 3 -> 3 retry: 4
01-12 09:57:37.026: D/ATRecorder(9072): com.htc.autotest.dlib.RecordEngine in loader dalvik.system.DexClassLoader@405d2328
01-12 09:57:37.046: D/WindowManagerImpl(9072): addView, new view, mViews[0]: com.android.internal.policy.impl.PhoneWindow$DecorView@405220f0
01-12 09:57:37.056: I/keystore(1270): uid: 1000 action: e -> 7 state: 3 -> 3 retry: 4
01-12 09:57:37.117: D/PhoneApp(1491): EVENT_QUERY_MO_PACKAGES
01-12 09:57:37.137: D/libEGL(9072): loaded /system/lib/egl/libGLES_android.so
01-12 09:57:37.147: D/WindowManagerImpl(1369): finishRemoveViewLocked, mViews[1]: com.android.internal.policy.impl.PhoneWindow$DecorView@40957078
01-12 09:57:37.147: I/ActivityManager(1369): Displayed com.example..../.MainActivity: +931ms
. 01-12 09:57:37.147: W/SchedPolicy(9072): add_tid_to_cgroup failed to write '' (Invalid argument); background=0
01-12 09:57:37.157: D/libEGL(9072): loaded /system/lib/egl/libEGL_adreno200.so
01-12 09:57:37.157: W/InputManagerService(1369): [unbindCurrentClientLocked] Disable input method client.
01-12 09:57:37.157: W/InputManagerService(1369): [startInputLocked] Enable input method client.
01-12 09:57:37.187: D/libEGL(9072): loaded /system/lib/egl/libGLESv1_CM_adreno200.so

推荐答案

com.google.android.gms.maps.MapFragment 使用,而不是使用 com.google.android.gms.maps.SupportMapFragment 并为活动它必须切换为 FragmentActivity 中提到的注释下

instead of using com.google.android.gms.maps.MapFragment use com.google.android.gms.maps.SupportMapFragment and for the Activity it will have to switched to be FragmentActivity as mentioned in the comment below

这篇关于如何使用谷歌地图API V2与API 10级?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆