问题描述:

I am trying the Google maps API example, but when I run the code emulator gives the error "The Application has stopped unexpectedly". I have put down the Logcat details below and also attached the screenshot of the error.


02-24 13:31:42.841: ERROR/AndroidRuntime(676): FATAL EXCEPTION: main

02-24 13:31:42.841: ERROR/AndroidRuntime(676): java.lang.RuntimeException: Unable to start activity ComponentInfo{net.learn2develope.GoogleMaps/net.learn2develope.GoogleMaps.MapsActivity}: android.view.InflateException: Binary XML file line #6: Error inflating class com.google.android.maps.MapView

02-24 13:31:42.841: ERROR/AndroidRuntime(676): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1622)

02-24 13:31:42.841: ERROR/AndroidRuntime(676): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1638)

02-24 13:31:42.841: ERROR/AndroidRuntime(676): at android.app.ActivityThread.access$1500(ActivityThread.java:117)

02-24 13:31:42.841: ERROR/AndroidRuntime(676): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:928)

02-24 13:31:42.841: ERROR/AndroidRuntime(676): at android.os.Handler.dispatchMessage(Handler.java:99)

02-24 13:31:42.841: ERROR/AndroidRuntime(676): at android.os.Looper.loop(Looper.java:123)

02-24 13:31:42.841: ERROR/AndroidRuntime(676): at android.app.ActivityThread.main(ActivityThread.java:3647)

02-24 13:31:42.841: ERROR/AndroidRuntime(676): at java.lang.reflect.Method.invokeNative(Native Method)

02-24 13:31:42.841: ERROR/AndroidRuntime(676): at java.lang.reflect.Method.invoke(Method.java:507)

02-24 13:31:42.841: ERROR/AndroidRuntime(676): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)

02-24 13:31:42.841: ERROR/AndroidRuntime(676): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)

02-24 13:31:42.841: ERROR/AndroidRuntime(676): at dalvik.system.NativeStart.main(Native Method)

02-24 13:31:42.841: ERROR/AndroidRuntime(676): Caused by: android.view.InflateException: Binary XML file line #6: Error inflating class com.google.android.maps.MapView

02-24 13:31:42.841: ERROR/AndroidRuntime(676): at android.view.LayoutInflater.createView(LayoutInflater.java:518)

02-24 13:31:42.841: ERROR/AndroidRuntime(676): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:570)

02-24 13:31:42.841: ERROR/AndroidRuntime(676): at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)

02-24 13:31:42.841: ERROR/AndroidRuntime(676): at android.view.LayoutInflater.inflate(LayoutInflater.java:408)

02-24 13:31:42.841: ERROR/AndroidRuntime(676): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)

02-24 13:31:42.841: ERROR/AndroidRuntime(676): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)

02-24 13:31:42.841: ERROR/AndroidRuntime(676): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)

02-24 13:31:42.841: ERROR/AndroidRuntime(676): at android.app.Activity.setContentView(Activity.java:1657)

02-24 13:31:42.841: ERROR/AndroidRuntime(676): at net.learn2develope.GoogleMaps.MapsActivity.onCreate(MapsActivity.java:11)

02-24 13:31:42.841: ERROR/AndroidRuntime(676): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)

02-24 13:31:42.841: ERROR/AndroidRuntime(676): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1586)

02-24 13:31:42.841: ERROR/AndroidRuntime(676): ... 11 more

02-24 13:31:42.841: ERROR/AndroidRuntime(676): Caused by: java.lang.reflect.InvocationTargetException

02-24 13:31:42.841: ERROR/AndroidRuntime(676): at java.lang.reflect.Constructor.constructNative(Native Method)

02-24 13:31:42.841: ERROR/AndroidRuntime(676): at java.lang.reflect.Constructor.newInstance(Constructor.java:415)

02-24 13:31:42.841: ERROR/AndroidRuntime(676): at android.view.LayoutInflater.createView(LayoutInflater.java:505)

02-24 13:31:42.841: ERROR/AndroidRuntime(676): ... 21 more

02-24 13:31:42.841: ERROR/AndroidRuntime(676): Caused by: java.lang.IllegalArgumentException: MapViews can only be created inside instances of MapActivity.

02-24 13:31:42.841: ERROR/AndroidRuntime(676): at com.google.android.maps.MapView.<init>(MapView.java:291)

02-24 13:31:42.841: ERROR/AndroidRuntime(676): at com.google.android.maps.MapView.<init>(MapView.java:264)

02-24 13:31:42.841: ERROR/AndroidRuntime(676): at com.google.android.maps.MapView.<init>(MapView.java:247)

02-24 13:31:42.841: ERROR/AndroidRuntime(676): ... 24 more


网友答案:

What's the class where you're using it? Does that class extend MapActivity ?

According to your errors, it should.

相关阅读:
Top