2012-04-17 131 views
1

我不断收到此错误,我不知道这个错误发生此XML文件InflateException:二进制XML文件行#60:错误充气类com.google.android.maps.MapView

?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 

</LinearLayout> 

这里,它是日志猫

04-17 02:19:25.556: W/dalvikvm(731): threadid=1: thread exiting with uncaught exception (group=0x4001d800) 
04-17 02:19:25.586: E/AndroidRuntime(731): FATAL EXCEPTION: main 
04-17 02:19:25.586: E/AndroidRuntime(731): java.lang.RuntimeException: Unable to start activity ComponentInfo{sbn.project.gp/sbn.project.gp.Mainevent}: android.view.InflateException: Binary XML file line #60: Error inflating class com.google.android.maps.MapView 
04-17 02:19:25.586: E/AndroidRuntime(731): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663) 
04-17 02:19:25.586: E/AndroidRuntime(731): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) 
04-17 02:19:25.586: E/AndroidRuntime(731): at android.app.ActivityThread.access$2300(ActivityThread.java:125) 
04-17 02:19:25.586: E/AndroidRuntime(731): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033) 
04-17 02:19:25.586: E/AndroidRuntime(731): at android.os.Handler.dispatchMessage(Handler.java:99) 
04-17 02:19:25.586: E/AndroidRuntime(731): at android.os.Looper.loop(Looper.java:123) 
04-17 02:19:25.586: E/AndroidRuntime(731): at android.app.ActivityThread.main(ActivityThread.java:4627) 
04-17 02:19:25.586: E/AndroidRuntime(731): at java.lang.reflect.Method.invokeNative(Native Method) 
04-17 02:19:25.586: E/AndroidRuntime(731): at java.lang.reflect.Method.invoke(Method.java:521) 
04-17 02:19:25.586: E/AndroidRuntime(731): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) 
04-17 02:19:25.586: E/AndroidRuntime(731): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 
04-17 02:19:25.586: E/AndroidRuntime(731): at dalvik.system.NativeStart.main(Native Method) 
04-17 02:19:25.586: E/AndroidRuntime(731): Caused by: android.view.InflateException: Binary XML file line #60: Error inflating class com.google.android.maps.MapView 
04-17 02:19:25.586: E/AndroidRuntime(731): at android.view.LayoutInflater.createView(LayoutInflater.java:513) 
04-17 02:19:25.586: E/AndroidRuntime(731): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:565) 
04-17 02:19:25.586: E/AndroidRuntime(731): at android.view.LayoutInflater.rInflate(LayoutInflater.java:618) 
04-17 02:19:25.586: E/AndroidRuntime(731): at android.view.LayoutInflater.inflate(LayoutInflater.java:407) 
04-17 02:19:25.586: E/AndroidRuntime(731): at android.view.LayoutInflater.inflate(LayoutInflater.java:320) 
04-17 02:19:25.586: E/AndroidRuntime(731): at android.view.LayoutInflater.inflate(LayoutInflater.java:276) 
04-17 02:19:25.586: E/AndroidRuntime(731): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198) 
04-17 02:19:25.586: E/AndroidRuntime(731): at android.app.Activity.setContentView(Activity.java:1647) 
04-17 02:19:25.586: E/AndroidRuntime(731): at sbn.project.gp.Mainevent.onCreate(Mainevent.java:27) 
04-17 02:19:25.586: E/AndroidRuntime(731): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 
04-17 02:19:25.586: E/AndroidRuntime(731): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627) 
04-17 02:19:25.586: E/AndroidRuntime(731): ... 11 more 
04-17 02:19:25.586: E/AndroidRuntime(731): Caused by: java.lang.reflect.InvocationTargetException 
04-17 02:19:25.586: E/AndroidRuntime(731): at com.google.android.maps.MapView.<init>(MapView.java:238) 
04-17 02:19:25.586: E/AndroidRuntime(731): at java.lang.reflect.Constructor.constructNative(Native Method) 
04-17 02:19:25.586: E/AndroidRuntime(731): at java.lang.reflect.Constructor.newInstance(Constructor.java:446) 
04-17 02:19:25.586: E/AndroidRuntime(731): at android.view.LayoutInflater.createView(LayoutInflater.java:500) 
04-17 02:19:25.586: E/AndroidRuntime(731): ... 21 more 
04-17 02:19:25.586: E/AndroidRuntime(731): Caused by: java.lang.IllegalArgumentException: MapViews can only be created inside instances of MapActivity. 
04-17 02:19:25.586: E/AndroidRuntime(731): at com.google.android.maps.MapView.<init>(MapView.java:282) 
04-17 02:19:25.586: E/AndroidRuntime(731): at com.google.android.maps.MapView.<init>(MapView.java:255) 

这里,它是Android清单

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="tt.pp.ss" 
    android:versionCode="1" 
    android:versionName="1.0" > 

    <uses-sdk android:minSdkVersion="8" /> 

    <uses-permission android:name="android.permission.INTERNET" /> 
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> 
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> 

    <application 
     android:icon="@drawable/ic_launcher" 
     android:label="@string/app_name" > 
     <uses-library android:name="com.google.android.maps" /> 
     <activity 
      android:name=".SbnActivity" 
      android:label="@string/app_name" > 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 

       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity> 

     <activity 

      android:name=".Main" 
      android:label="@string/app_name" > 
      <intent-filter> 
       <action android:name="tt.pp.ss.MAIN" /> 

       <category android:name="android.intent.category.DEFAULT" /> 
      </intent-filter> 
     </activity> 

     <activity 
      android:name=".Db" 
      android:label="@string/app_name" > 
      <intent-filter> 
       <action android:name="tt.pp.ss.DB" /> 

       <category android:name="android.intent.category.DEFAULT" /> 
      </intent-filter> 
     </activity> 
     <activity 
      android:name=".View" 
      android:label="@string/app_name" > 
      <intent-filter> 
       <action android:name="tt.pp.ss.VIEW" /> 

       <category android:name="android.intent.category.DEFAULT" /> 
      </intent-filter> 
     </activity> 
     <activity 
      android:name=".Mainevent" 
      android:label="@string/app_name" > 
      <intent-filter> 
       <action android:name="tt.pp.ss.MAINEVENT" /> 

       <category android:name="android.intent.category.DEFAULT" /> 
      </intent-filter> 
     </activity> 
     <activity 
      android:name=".Signup" 
      android:label="@string/app_name" > 
      <intent-filter> 
       <action android:name="tt.pp.ss.SIGNUP" /> 

       <category android:name="android.intent.category.DEFAULT" /> 
      </intent-filter> 
     </activity> 
    </application> 

</manifest> 

任何帮助,我花更多的塔N 5小时,我不能弄清楚。

回答

3
MapViews can only be created inside instances of MapActivity. 

您使用的是MapActivity吗?

+0

我正在处理几个类。我从中使用MapViews的类我扩展它从Mapactivity,但现在我想导航到其他正常的活动,我得到了那个错误 – 2012-04-17 00:38:53

+0

@KhaledMohamed仔细检查你的setContentView新活动将指向正确的XML文件 - 我最好的猜测是,你必须从一个复制/粘贴 – JRaymond 2012-04-17 00:42:45

+0

确定在那里留下的地图布局我将检查感谢您的帮助 – 2012-04-17 00:49:06

3

我以前有同样的问题,通过以下2个步骤来解决它:

1)把下面的行中AndroidManifest.xml文件的应用(重要)元件。

<uses-library android:name="com.google.android.maps" /> 

2)延伸MapActivity代替活性

+0

感谢。它完全为我工作。 – 2012-05-27 07:39:16

相关问题