应用程序在我运行时强行关闭?无法启动应用活动

时间:2012-02-29 21:33:20

标签: java android android-manifest logcat

当我跑步时,我会立即关闭力量。我永远无法理解logcat错误。我正在使用Eclipse和Android SDK。这是Logcat错误,但它是什么意思?

02-29 12:59:35.875: E/AndroidRuntime(9759): FATAL EXCEPTION: main
02-29 12:59:35.875: E/AndroidRuntime(9759): java.lang.RuntimeException: Unable to start activity ComponentInfo{izzy.n/izzy.n.IzzynActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
02-29 12:59:35.875: E/AndroidRuntime(9759):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
02-29 12:59:35.875: E/AndroidRuntime(9759):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
02-29 12:59:35.875: E/AndroidRuntime(9759):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
02-29 12:59:35.875: E/AndroidRuntime(9759):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
02-29 12:59:35.875: E/AndroidRuntime(9759):     at android.os.Handler.dispatchMessage(Handler.java:99)
02-29 12:59:35.875: E/AndroidRuntime(9759):     at android.os.Looper.loop(Looper.java:130)
02-29 12:59:35.875: E/AndroidRuntime(9759):     at android.app.ActivityThread.main(ActivityThread.java:3687)
02-29 12:59:35.875: E/AndroidRuntime(9759):     at java.lang.reflect.Method.invokeNative(Native Method)
02-29 12:59:35.875: E/AndroidRuntime(9759):     at java.lang.reflect.Method.invoke(Method.java:507)
02-29 12:59:35.875: E/AndroidRuntime(9759):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
02-29 12:59:35.875: E/AndroidRuntime(9759):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
02-29 12:59:35.875: E/AndroidRuntime(9759):     at dalvik.system.NativeStart.main(Native Method)
02-29 12:59:35.875: E/AndroidRuntime(9759): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
02-29 12:59:35.875: E/AndroidRuntime(9759):     at android.view.LayoutInflater.createView(LayoutInflater.java:518)
02-29 12:59:35.875: E/AndroidRuntime(9759):     at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
02-29 12:59:35.875: E/AndroidRuntime(9759):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
02-29 12:59:35.875: E/AndroidRuntime(9759):     at android.view.LayoutInflater.parseInclude(LayoutInflater.java:684)
02-29 12:59:35.875: E/AndroidRuntime(9759):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:619)
02-29 12:59:35.875: E/AndroidRuntime(9759):     at android.view.LayoutInflater.parseInclude(LayoutInflater.java:707)
02-29 12:59:35.875: E/AndroidRuntime(9759):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:619)
02-29 12:59:35.875: E/AndroidRuntime(9759):     at android.view.LayoutInflater.parseInclude(LayoutInflater.java:707)
02-29 12:59:35.875: E/AndroidRuntime(9759):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:619)
02-29 12:59:35.875: E/AndroidRuntime(9759):     at android.view.LayoutInflater.parseInclude(LayoutInflater.java:707)
02-29 12:59:35.875: E/AndroidRuntime(9759):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:619)
02-29 12:59:35.875: E/AndroidRuntime(9759):     at android.view.LayoutInflater.parseInclude(LayoutInflater.java:707)
02-29 12:59:35.875: E/AndroidRuntime(9759):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:619)
02-29 12:59:35.875: E/AndroidRuntime(9759):     at android.view.LayoutInflater.parseInclude(LayoutInflater.java:707)
02-29 12:59:35.875: E/AndroidRuntime(9759):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:619)
02-29 12:59:35.875: E/AndroidRuntime(9759):     at android.view.LayoutInflater.parseInclude(LayoutInflater.java:707)
02-29 12:59:35.875: E/AndroidRuntime(9759):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:619)
02-29 12:59:35.875: E/AndroidRuntime(9759):     at android.view.LayoutInflater.parseInclude(LayoutInflater.java:707)
02-29 12:59:35.875: E/AndroidRuntime(9759):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:619)
02-29 12:59:35.875: E/AndroidRuntime(9759):     at android.view.LayoutInflater.parseInclude(LayoutInflater.java:707)
02-29 12:59:35.875: E/AndroidRuntime(9759):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:619)
02-29 12:59:35.875: E/AndroidRuntime(9759):     at android.view.LayoutInflater.parseInclude(LayoutInflater.java:707)
02-29 12:59:35.875: E/AndroidRuntime(9759):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:619)
02-29 12:59:35.875: E/AndroidRuntime(9759):     at android.view.LayoutInflater.parseInclude(LayoutInflater.java:707)
02-29 12:59:35.875: E/AndroidRuntime(9759):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:619)
02-29 12:59:35.875: E/AndroidRuntime(9759):     at android.view.LayoutInflater.parseInclude(LayoutInflater.java:707)
02-29 12:59:35.875: E/AndroidRuntime(9759):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:619)
02-29 12:59:35.875: E/AndroidRuntime(9759):     at android.view.LayoutInflater.parseInclude(LayoutInflater.java:707)
02-29 12:59:35.875: E/AndroidRuntime(9759):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:619)
02-29 12:59:35.875: E/AndroidRuntime(9759):     at android.view.LayoutInflater.parseInclude(LayoutInflater.java:707)
02-29 12:59:35.875: E/AndroidRuntime(9759):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:619)
02-29 12:59:35.875: E/AndroidRuntime(9759):     at android.view.LayoutInflater.parseInclude(LayoutInflater.java:707)
02-29 12:59:35.875: E/AndroidRuntime(9759):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:619)
02-29 12:59:35.875: E/AndroidRuntime(9759):     at android.view.LayoutInflater.parseInclude(LayoutInflater.java:707)
02-29 12:59:35.875: E/AndroidRuntime(9759):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:619)
02-29 12:59:35.875: E/AndroidRuntime(9759):     at android.view.LayoutInflater.parseInclude(LayoutInflater.java:707)
02-29 12:59:35.875: E/AndroidRuntime(9759):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:619)
02-29 12:59:35.875: E/AndroidRuntime(9759):     at android.view.LayoutInflater.parseInclude(LayoutInflater.java:707)
02-29 12:59:35.875: E/AndroidRuntime(9759):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:619)
02-29 12:59:35.875: E/AndroidRuntime(9759):     at android.view.LayoutInflater.parseInclude(LayoutInflater.java:707)
02-29 12:59:35.875: E/AndroidRuntime(9759):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:619)
02-29 12:59:35.875: E/AndroidRuntime(9759):     at android.view.LayoutInflater.parseInclude(LayoutInflater.java:707)
02-29 12:59:35.875: E/AndroidRuntime(9759):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:619)
02-29 12:59:35.875: E/AndroidRuntime(9759):     at android.view.Layout
02-29 12:59:43.347: I/Process(9759): Sending signal. PID: 9759 SIG: 9

感谢帮助人

这是main.xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/bg"
    android:orientation="vertical" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

    <include
        android:id="@+id/include1"
        android:layout_width="160dp"
        android:layout_height="200dp"
        android:layout_marginRight="15dp"
        android:layout_marginTop="280dp"
        layout="@layout/main" />




 <Button
        android:id="@+id/button1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_marginBottom="69dp"
        android:text="@string/button1" />

</RelativeLayout>

这是AndroidActivity(main.xml的Java文件)

package izzy.n;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.Manifest;



public class IzzynActivity extends Activity{

    /** Called when the activity is first created. */
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Button wg = (Button) findViewById(R.id.button1);
        wg.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                Intent myIntent = new Intent(IzzynActivity.this, notes.class);
                IzzynActivity.this.startActivity(myIntent);
            }

        });


    }
}

这是Android Manifest:

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

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

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:name="izzy.n.IzzynActivity"
            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="izzy.n.notes"
            android:label="@string/notes"></activity>
    </application>

</manifest>

2 个答案:

答案 0 :(得分:2)

这个属性在你的xml中似乎有问题:

layout="@layout/main"

您无法在其中包含布局。它就像一个黑洞:))

只需删除包含视图,我希望它可以正常工作

答案 1 :(得分:0)

好的,有几点意见:

一个。删除

  

android:orientation =“vertical”

来自RelativeLayout的

作为android:orientation只与LinearLayout相关

湾删除

 <include ...  layout="@layout/main" />

因为你递归地包括主要内部?