1

我不断收到这个错误,我不知道这个错误发生在哪里这个 xml 文件

?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>

我花了超过 5 个小时的任何帮助,但我无法弄清楚。

4

2 回答 2

3
MapViews can only be created inside instances of MapActivity.

你在使用 MapActivity 吗?

于 2012-04-17T00:33:16.617 回答
3

我之前遇到过同样的问题,通过以下两个步骤解决了:

1) 将以下行放入 AndroidManifest.xml 文件的应用程序(重要)元素中。

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

2)扩展MapActivity而不是Activity

于 2012-04-30T10:16:48.967 回答