根據1發佈的代碼可用於Android API 12或更高版本。我試圖在具有API等級10(谷歌API平臺2.3.3)仿真器的代碼,我得到以下著名錯誤:
如何使用API 10級的Google Maps API v2?
E/AndroidRuntime( 429): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example..../com.example....MainActivity}: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
我複製粘貼下面我.xml文件。
<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"/>
所以我假定片段元素是不支持...(?)。我嘗試相同的代碼與API級別17的仿真器和我得到的消息(這是我讀書是目前仿真器的問題):
This app won't run unless you update Google Play Services.
我沒有爲17級到真實設備測試它,但我認爲它可能工作。
上面的代碼專門針對10級有任何錯誤嗎? Google目前支持哪些代碼,以便在API級別爲10的Android設備中開發地圖?
1https://developers.google.com/maps/documentation/android/start
UPDATE: 更改爲FragmentActivity
和SupportMapFragment
後,我得到如下:
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秒後:
Google Maps Android API Authorization failure
更新2: 我改變了項目建設目標爲Android 10(我有它的android 4.2)。所以現在我沒有看到授權失敗)。我也貼上谷歌我的API訪問。
我沒有在項目的.properties中啓用proguard,即,:
# 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
# Project target.
target=android-10
android.library.reference.1=../../adt-bundle-windows-x86/sdk/extras/google/google_play_services/libproject/google-play-services_lib
問題仍然存在:
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.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 [email protected]
01-12 09:57:37.046: D/WindowManagerImpl(9072): addView, new view, mViews[0]: [email protected]
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]: [email protected]
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
我有Ť他同樣的問題「找不到類'maps.j.k',從方法maps.y.ae.a引用」我正在使用版本2.3.6的Nexus One上運行我試過以下內容:1. Made確定我的控制檯已選擇Android Maps API V2 2.重新創建了我的API密鑰(我沒有收到授權錯誤) 3.將我的目標更改爲Google API 4.2 4.使用SupportMapFragment和FragmentActivity 5.檢查了我的根據提供的示例代碼清單條目 6.檢查包括谷歌播放服務庫 7.更新谷歌地圖,谷歌播放我的設備我不知道還有什麼要嘗試。 – quark