我收到一个错误:ActivityNotFoundException

时间:2017-10-06 19:24:17

标签: android classnotfoundexception

我删除了.TwoBase并将其替换为.Tutorial_1但是,当我点击主菜单上的第一个按钮(对于.Tutorial_1)时应用程序崩溃了,我仍然记录了这个日志来自Android Monitor:

10-07 02:55:22.960 28283-28283/com.facebook.texttospeech E/AndroidRuntime: FATAL EXCEPTION: main
                                                                       Process: com.facebook.texttospeech, PID: 28283
                                                                       android.content.ActivityNotFoundException: Unable to find explicit activity class {com.facebook.texttospeech/com.android.howtodrawchibi.TwoBase}; have you declared this activity in your AndroidManifest.xml?
                                                                           at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1777)
                                                                           at android.app.Instrumentation.execStartActivity(Instrumentation.java:1501)
                                                                           at android.app.Activity.startActivityForResult(Activity.java:3760)
                                                                           at android.app.Activity.startActivityForResult(Activity.java:3721)
                                                                           at android.app.Activity.startActivity(Activity.java:4033)
                                                                           at android.app.Activity.startActivity(Activity.java:3999)
                                                                           at com.android.howtodrawchibi.MainMenu$1.onClick(MainMenu.java:36)
                                                                           at android.view.View.performClick(View.java:4791)
                                                                           at android.view.View$PerformClick.run(View.java:19884)
                                                                           at android.os.Handler.handleCallback(Handler.java:739)
                                                                           at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                           at android.os.Looper.loop(Looper.java:135)
                                                                           at android.app.ActivityThread.main(ActivityThread.java:5345)
                                                                           at java.lang.reflect.Method.invoke(Native Method)
                                                                           at java.lang.reflect.Method.invoke(Method.java:372)
                                                                           at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:947)
                                                                           at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:742)

此处打开.MainMenu

.Tutorial_1
public class MainMenu extends Activity {

Button button;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    addListenerOnButton();
}



public void addListenerOnButton() {

    final Context context = this;

    button = (Button) findViewById(R.id.button1);

    button.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {

            Intent intent = new Intent(context, Tutorial_1.class);
            startActivity(intent);

        }

    });


    button = (Button) findViewById(R.id.button3);

    button.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {

            Intent intent = new Intent(context, MainActivity.class);
            startActivity(intent);

        }

    });


    button = (Button) findViewById(R.id.button4);

    button.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {


            Intent intent = new Intent(context, About.class);
            startActivity(intent);

        }

    });

}

这是我替换为.Tutorial_1的{​​{1}}活动:

.TwoBase

最后,这里是android清单:

 public class Tutorial_1 extends Activity{

        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.twobase_activity);
        }
}

0 个答案:

没有答案