2013-03-09 45 views
0

所以我找到了一個教程here。但即使在真實的設備上,我也無法運行它。我發現類似問題here和20個其他頁面,所有人都有我的問題,但我不明白爲什麼谷歌地圖不適用於Android。這是Logcat中的錯誤。爲什麼Google地圖不適用於Android API 2?

03-09 23:06:22.050: D/dalvikvm(28176): Late-enabling CheckJNI 
03-09 23:06:22.277: W/dalvikvm(28176): VFY: unable to resolve static field 874 (MapAttrs) in Lcom/google/android/gms/R$styleable; 
03-09 23:06:22.277: D/dalvikvm(28176): VFY: replacing opcode 0x62 at 0x000e 
03-09 23:06:22.285: D/AndroidRuntime(28176): Shutting down VM 
03-09 23:06:22.285: W/dalvikvm(28176): threadid=1: thread exiting with uncaught exception (group=0x40bbe1f8) 
03-09 23:06:22.285: E/AndroidRuntime(28176): FATAL EXCEPTION: main 
03-09 23:06:22.285: E/AndroidRuntime(28176): java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable 
03-09 23:06:22.285: E/AndroidRuntime(28176): at com.google.android.gms.maps.GoogleMapOptions.createFromAttributes(Unknown Source) 
03-09 23:06:22.285: E/AndroidRuntime(28176): at com.google.android.gms.maps.MapFragment.onInflate(Unknown Source) 
03-09 23:06:22.285: E/AndroidRuntime(28176): at android.app.Activity.onCreateView(Activity.java:4242) 
03-09 23:06:22.285: E/AndroidRuntime(28176): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:673) 
03-09 23:06:22.285: E/AndroidRuntime(28176): at android.view.LayoutInflater.rInflate(LayoutInflater.java:739) 
03-09 23:06:22.285: E/AndroidRuntime(28176): at android.view.LayoutInflater.inflate(LayoutInflater.java:489) 
03-09 23:06:22.285: E/AndroidRuntime(28176): at android.view.LayoutInflater.inflate(LayoutInflater.java:396) 
03-09 23:06:22.285: E/AndroidRuntime(28176): at android.view.LayoutInflater.inflate(LayoutInflater.java:352) 
03-09 23:06:22.285: E/AndroidRuntime(28176): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:273) 
03-09 23:06:22.285: E/AndroidRuntime(28176): at android.app.Activity.setContentView(Activity.java:1835) 
03-09 23:06:22.285: E/AndroidRuntime(28176): at com.alirezasaremi.showmap.ShowMapActivity.onCreate(ShowMapActivity.java:23) 
03-09 23:06:22.285: E/AndroidRuntime(28176): at android.app.Activity.performCreate(Activity.java:4465) 
03-09 23:06:22.285: E/AndroidRuntime(28176): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1053) 
03-09 23:06:22.285: E/AndroidRuntime(28176): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1934) 
03-09 23:06:22.285: E/AndroidRuntime(28176): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1995) 
03-09 23:06:22.285: E/AndroidRuntime(28176): at android.app.ActivityThread.access$600(ActivityThread.java:128) 
03-09 23:06:22.285: E/AndroidRuntime(28176): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1161) 
03-09 23:06:22.285: E/AndroidRuntime(28176): at android.os.Handler.dispatchMessage(Handler.java:99) 
03-09 23:06:22.285: E/AndroidRuntime(28176): at android.os.Looper.loop(Looper.java:137) 
03-09 23:06:22.285: E/AndroidRuntime(28176): at android.app.ActivityThread.main(ActivityThread.java:4514) 
03-09 23:06:22.285: E/AndroidRuntime(28176): at java.lang.reflect.Method.invokeNative(Native Method) 
03-09 23:06:22.285: E/AndroidRuntime(28176): at java.lang.reflect.Method.invoke(Method.java:511) 
03-09 23:06:22.285: E/AndroidRuntime(28176): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790) 
03-09 23:06:22.285: E/AndroidRuntime(28176): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557) 
03-09 23:06:22.285: E/AndroidRuntime(28176): at dalvik.system.NativeStart.main(Native Method) 

有人可以幫我嗎?

+0

這可以幫助HTTP:/ /stackoverflow.com/questions/13691028/noclassdeffounderror-at-google-play-services-v2-library/14686856#14686856 – DjHacktorReborn 2013-03-09 19:42:55

+0

@DjHacktorReborn ::謝謝,但同樣的錯誤仍然出現。 – IndieBoy 2013-03-09 20:04:03

+0

我認爲這將解決您的問題http://stackoverflow.com/questions/13696620/google-maps-android-api-v2-authorization-failure – DjHacktorReborn 2013-03-09 20:06:21

回答

0

我知道這個錯誤:java.lang.NoClassDefFoundError:com.google.android.gms.R $設置樣式

你應該導入谷歌播放服務的lib項目到工作區,而不僅僅是添加外部JAR項目。以下是詳細信息:

Android developers topic related 「的/演員/谷歌/ google_play_services/libproject /谷歌播放services_lib庫項目複製到源代碼樹,你保持你的Android應用項目 如果您使用的是Eclipse,進口。將庫項目放入工作區中,單擊文件>導入,選擇Android>將Android代碼添加到Workspace中,然後瀏覽到該庫項目的副本以導入它。

0

這裏是一個博客帖子我就如何在谷歌地圖API V2添加到您的應用程序中寫道。 請密切關注,以谷歌的播放服務項目添加到您的工作空間中的第4步,然後從項目創建對它的引用:

Creating Google Map API V2

相關問題