如何解决FATAL EXCEPTION:主要在eclipse中

时间:2015-11-12 08:51:52

标签: java android eclipse

我遇到了这个致命异常的问题:主要阻止我从我的应用程序的主菜单移动。 我是初学者,所以即使你告诉我要注意错误我也不知道这里是我的logcat

11-12 07:17:19.034: D/AndroidRuntime(284): Shutting down VM
11-12 07:17:19.034: W/dalvikvm(284): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
11-12 07:17:19.104: E/AndroidRuntime(284): FATAL EXCEPTION: main
11-12 07:17:19.104: E/AndroidRuntime(284): android.content.ActivityNotFoundException: Unable to find explicit activity class {kamus.indonesia.toraja/kamus.indonesia.toraja.Option}; have you declared this activity in your AndroidManifest.xml?
11-12 07:17:19.104: E/AndroidRuntime(284):  at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1404)
11-12 07:17:19.104: E/AndroidRuntime(284):  at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
11-12 07:17:19.104: E/AndroidRuntime(284):  at android.app.Activity.startActivityForResult(Activity.java:2817)
11-12 07:17:19.104: E/AndroidRuntime(284):  at android.app.Activity.startActivity(Activity.java:2923)
11-12 07:17:19.104: E/AndroidRuntime(284):  at kamus.indonesia.toraja.MainActivity$1.onClick(MainActivity.java:33)
11-12 07:17:19.104: E/AndroidRuntime(284):  at android.view.View.performClick(View.java:2408)
11-12 07:17:19.104: E/AndroidRuntime(284):  at android.view.View$PerformClick.run(View.java:8816)
11-12 07:17:19.104: E/AndroidRuntime(284):  at android.os.Handler.handleCallback(Handler.java:587)
11-12 07:17:19.104: E/AndroidRuntime(284):  at android.os.Handler.dispatchMessage(Handler.java:92)
11-12 07:17:19.104: E/AndroidRuntime(284):  at android.os.Looper.loop(Looper.java:123)
11-12 07:17:19.104: E/AndroidRuntime(284):  at android.app.ActivityThread.main(ActivityThread.java:4627)
11-12 07:17:19.104: E/AndroidRuntime(284):  at java.lang.reflect.Method.invokeNative(Native Method)
11-12 07:17:19.104: E/AndroidRuntime(284):  at java.lang.reflect.Method.invoke(Method.java:521)
11-12 07:17:19.104: E/AndroidRuntime(284):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
11-12 07:17:19.104: E/AndroidRuntime(284):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
11-12 07:17:19.104: E/AndroidRuntime(284):  at dalvik.system.NativeStart.main(Native Method)
11-12 07:19:36.066: I/Process(284): Sending signal. PID: 284 SIG: 9

我试图搜索并解决它,但我不知道问题出在哪里以及问题出在哪里......

这是我的androidmanifest.xml

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

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

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >
    <activity
        android:label="@string/app_name"
        android:name=".MainActivity" >
        <intent-filter >
            <action android:name="android.intent.action.MAIN" />

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

</manifest>

我非常感谢你的帮助 这是我的mainactivity.class

package kamus.indonesia.toraja;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class MainActivity extends Activity {
    /** Called when the activity is first created. */
    Button translateMenu;
    Button insertMenu;
    Button deleteMenu;
    Button helpMenu;
    DbHelper db;
    @Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    translateMenu = (Button) findViewById(R.id.btnMenerjemahkan);
    insertMenu = (Button) findViewById(R.id.btnTambahKata);
    deleteMenu = (Button) findViewById(R.id.btnHapusKata);
    helpMenu = (Button) findViewById(R.id.btnManual);

    translateMenu.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            // TODO Auto-generated method stub
            Intent trans = new Intent(MainActivity.this,Option.class);
            trans.putExtra("pesan","From Main Activity Menu");
            //trans.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(trans);
        }
    });

    insertMenu.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            // TODO Auto-generated method stub
            Intent insert = new Intent(MainActivity.this,TambahKata.class);
            insert.putExtra("pesan","From Main Activity Menu");
            //insert.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(insert);

        }
    });

    deleteMenu.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            // TODO Auto-generated method stub
            Intent delete = new Intent(MainActivity.this,HapusKata.class);
            delete.putExtra("pesan","From Main Activity Menu");
            //delete.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(delete);
        }
    });

    helpMenu.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            // TODO Auto-generated method stub
            Intent help = new Intent(MainActivity.this,Manual.class);
            help.putExtra("pesan","From Main Activity Menu");
            //help.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        }
    });
}
}

已解决^ _ ^谢谢

1 个答案:

答案 0 :(得分:0)

您有一些名为OptionTambahKataHapusKataManual的活动,但您未在AndroidManifest中声明。

将这些内容添加到您的AndroidManifest

<activity
    android:label="@string/app_name"
    android:name="kamus.indonesia.toraja.Option" >
</activity>

<activity
    android:label="@string/app_name"
    android:name="kamus.indonesia.toraja.TambahKata" >
</activity>

<activity
    android:label="@string/app_name"
    android:name="kamus.indonesia.toraja.HapusKata" >
</activity>

<activity
    android:label="@string/app_name"
    android:name="kamus.indonesia.toraja.Manual" >
</activity>

这样您的AndroidManifest将如下所示:

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

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

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >
    <activity
        android:label="@string/app_name"
        android:name=".MainActivity" >
        <intent-filter >
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:label="@string/app_name"
        android:name="kamus.indonesia.toraja.Option" >
    </activity>

    <activity
        android:label="@string/app_name"
        android:name="kamus.indonesia.toraja.TambahKata" >
    </activity>

    <activity
        android:label="@string/app_name"
        android:name="kamus.indonesia.toraja.HapusKata" >
    </activity>

    <activity
        android:label="@string/app_name"
        android:name="kamus.indonesia.toraja.Manual" >
    </activity>
</application>

</manifest>