1

UPDATE:

In my Android SDK Manager, I have the Android Support Library installed. In my Downloads/android-sdk-macosx/extras/android/support directory, I have a v4, a v7, and v13. I copied android-support-v4.jar to the libs folder. Right clicked and selected Build Path > Configure Build Path. In the activity layout I added the following (using supportmapfragment rather than mapfragment):

<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.SupportMapFragment"/> 

But still I get this error:

04-16 17:42:00.928: E/AndroidRuntime(363): FATAL EXCEPTION: main 
04-16 17:42:00.928: E/AndroidRuntime(363): 
java.lang.RuntimeException: 
Unable to start activity ComponentInfo{com.otl.AndroidRemoteApp1/ 
com.otl.AndroidRemoteApp.ShowMapActivity}: 
android.view.InflateException: Binary XML file line #6: Error 
inflating class fragment 

Here's the full trace:

04-18 10:33:32.075: E/AndroidRuntime(368): FATAL EXCEPTION: main
04-18 10:33:32.075: E/AndroidRuntime(368): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.otl.AndroidRemoteApp1/com.otl.AndroidRemoteApp.ShowMapActivity}: android.view.InflateException: Binary XML file line #6: Error inflating class fragment
04-18 10:33:32.075: E/AndroidRuntime(368):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
04-18 10:33:32.075: E/AndroidRuntime(368):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
04-18 10:33:32.075: E/AndroidRuntime(368):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)
04-18 10:33:32.075: E/AndroidRuntime(368):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
04-18 10:33:32.075: E/AndroidRuntime(368):  at android.os.Handler.dispatchMessage(Handler.java:99)
04-18 10:33:32.075: E/AndroidRuntime(368):  at android.os.Looper.loop(Looper.java:130)
04-18 10:33:32.075: E/AndroidRuntime(368):  at android.app.ActivityThread.main(ActivityThread.java:3683)
04-18 10:33:32.075: E/AndroidRuntime(368):  at java.lang.reflect.Method.invokeNative(Native Method)
04-18 10:33:32.075: E/AndroidRuntime(368):  at java.lang.reflect.Method.invoke(Method.java:507)
04-18 10:33:32.075: E/AndroidRuntime(368):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
04-18 10:33:32.075: E/AndroidRuntime(368):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
04-18 10:33:32.075: E/AndroidRuntime(368):  at dalvik.system.NativeStart.main(Native Method)
04-18 10:33:32.075: E/AndroidRuntime(368): Caused by: android.view.InflateException: Binary XML file line #6: Error inflating class fragment
04-18 10:33:32.075: E/AndroidRuntime(368):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:581)
04-18 10:33:32.075: E/AndroidRuntime(368):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
04-18 10:33:32.075: E/AndroidRuntime(368):  at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
04-18 10:33:32.075: E/AndroidRuntime(368):  at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
04-18 10:33:32.075: E/AndroidRuntime(368):  at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
04-18 10:33:32.075: E/AndroidRuntime(368):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
04-18 10:33:32.075: E/AndroidRuntime(368):  at android.app.Activity.setContentView(Activity.java:1657)
04-18 10:33:32.075: E/AndroidRuntime(368):  at com.otl.AndroidRemoteApp.ShowMapActivity.onCreate(ShowMapActivity.java:45)
04-18 10:33:32.075: E/AndroidRuntime(368):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-18 10:33:32.075: E/AndroidRuntime(368):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
04-18 10:33:32.075: E/AndroidRuntime(368):  ... 11 more
04-18 10:33:32.075: E/AndroidRuntime(368): Caused by: java.lang.ClassNotFoundException: android.view.fragment in loader dalvik.system.PathClassLoader[/system/framework/com.google.android.maps.jar:/data/app/com.otl.AndroidRemoteApp1-2.apk]
04-18 10:33:32.075: E/AndroidRuntime(368):  at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
04-18 10:33:32.075: E/AndroidRuntime(368):  at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
04-18 10:33:32.075: E/AndroidRuntime(368):  at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
04-18 10:33:32.075: E/AndroidRuntime(368):  at android.view.LayoutInflater.createView(LayoutInflater.java:471)
04-18 10:33:32.075: E/AndroidRuntime(368):  at android.view.LayoutInflater.onCreateView(LayoutInflater.java:549)
04-18 10:33:32.075: E/AndroidRuntime(368):  at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
04-18 10:33:32.075: E/AndroidRuntime(368):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
04-18 10:33:32.075: E/AndroidRuntime(368):  ... 20 more

Any ideas?

JohnMerlino
  • 3,900
  • 4
  • 57
  • 89

1 Answers1

2

The MapFragment is supported only after API Level 12. It is recommended to use the SupportMapFragment instead.

To use this you will need the Android Support Library included to your path. Follow these instructions to add the support library to your project.

UPDATE:

In addition, the Fragment class is not available until API Level 11. I believe you are targeting Gingerbread which is API Level 10. This is why you are getting the error below:

Caused by: java.lang.ClassNotFoundException: android.view.fragment in loader dalvik.system.PathClassLoader

See this Question, it looks to be a similar problem.

Community
  • 1
  • 1
Phil Applegate
  • 567
  • 2
  • 9
  • When I go to the Android SDK Manager, under Extras, it shows that "Android Support Library" is already installed. The documentation you linked to says that files (including source code, samples, and the .jar files) are saved into the /extras/android/support/ directory. However, when I go to that directory on my hard drive (Downloads/android-sdk-macosx/extras/android/support), I only see v4, v7, v13. My app alreayd has the android-support-v4.jar file installed in the libs directory. I guess I need the v2.3.jar. How do I get it? – JohnMerlino Apr 17 '13 at 15:56
  • Are there any more lines in LogCat further down? Does it give a "Caused By"? Can you post the rest of the log please? – Phil Applegate Apr 18 '13 at 07:07
  • I added the full stacktrace – JohnMerlino Apr 18 '13 at 14:35
  • The error went away. Im going to test it on a gingerbread device and then upvote your answer. – JohnMerlino Apr 19 '13 at 21:20
  • Thanks - any issues give me a shout. – Phil Applegate Apr 22 '13 at 11:44