Java 月食“;抱歉-应用程序(Appname)意外停止。请再试一次;

Java 月食“;抱歉-应用程序(Appname)意外停止。请再试一次;,java,android,xml,eclipse,manifest,Java,Android,Xml,Eclipse,Manifest,嘿,我是安卓编码的乞丐,我一直在youtube上关注这个系列。每当我将我的项目作为android应用程序运行并转到模拟器选择它时,它都会给我“对不起-应用程序(Appname)意外停止。请重试”Eclipse不会给我任何关于问题所在的错误行,因此非常令人沮丧。。我一直在网上寻找这个问题的答案,但我一直没能解决它。我想这和我的舱单有关。每当我运行应用程序时,我的LogCat上都会出现错误 我的应用程序是一个小应用程序,当被选中时,它将首先打开一个徽标屏幕3秒钟,然后它将带您进入一个界面,其中有2个

嘿,我是安卓编码的乞丐,我一直在youtube上关注这个系列。每当我将我的项目作为android应用程序运行并转到模拟器选择它时,它都会给我“对不起-应用程序(Appname)意外停止。请重试”Eclipse不会给我任何关于问题所在的错误行,因此非常令人沮丧。。我一直在网上寻找这个问题的答案,但我一直没能解决它。我想这和我的舱单有关。每当我运行应用程序时,我的LogCat上都会出现错误

我的应用程序是一个小应用程序,当被选中时,它将首先打开一个徽标屏幕3秒钟,然后它将带您进入一个界面,其中有2个按钮可供选择。两个按钮都会导致编辑文本

我把我所有的代码都贴在下面,请大家记住,当你们回答我是一个乞丐,可能不懂一些术语。谢谢大家!

这是我试着启动时的日志

07-20 20:19:17.382: D/dalvikvm(254): GC_EXTERNAL_ALLOC freed 663 objects / 51912 bytes in 177ms
07-20 20:19:19.791: D/AndroidRuntime(254): Shutting down VM
07-20 20:19:19.801: W/dalvikvm(254): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
07-20 20:19:19.811: E/AndroidRuntime(254): FATAL EXCEPTION: main
07-20 20:19:19.811: E/AndroidRuntime(254): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.thepasics/com.example.thepasics.Menu}: java.lang.ClassNotFoundException: com.example.thepasics.Menu in loader dalvik.system.PathClassLoader[/data/app/com.example.thepasics-2.apk]
07-20 20:19:19.811: E/AndroidRuntime(254):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
07-20 20:19:19.811: E/AndroidRuntime(254):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
07-20 20:19:19.811: E/AndroidRuntime(254):  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
07-20 20:19:19.811: E/AndroidRuntime(254):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
07-20 20:19:19.811: E/AndroidRuntime(254):  at android.os.Handler.dispatchMessage(Handler.java:99)
07-20 20:19:19.811: E/AndroidRuntime(254):  at android.os.Looper.loop(Looper.java:123)
07-20 20:19:19.811: E/AndroidRuntime(254):  at android.app.ActivityThread.main(ActivityThread.java:4627)
07-20 20:19:19.811: E/AndroidRuntime(254):  at java.lang.reflect.Method.invokeNative(Native Method)
07-20 20:19:19.811: E/AndroidRuntime(254):  at java.lang.reflect.Method.invoke(Method.java:521)
07-20 20:19:19.811: E/AndroidRuntime(254):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
07-20 20:19:19.811: E/AndroidRuntime(254):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
07-20 20:19:19.811: E/AndroidRuntime(254):  at dalvik.system.NativeStart.main(Native Method)
07-20 20:19:19.811: E/AndroidRuntime(254): Caused by: java.lang.ClassNotFoundException: com.example.thepasics.Menu in loader dalvik.system.PathClassLoader[/data/app/com.example.thepasics-2.apk]
07-20 20:19:19.811: E/AndroidRuntime(254):  at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
07-20 20:19:19.811: E/AndroidRuntime(254):  at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
07-20 20:19:19.811: E/AndroidRuntime(254):  at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
07-20 20:19:19.811: E/AndroidRuntime(254):  at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
07-20 20:19:19.811: E/AndroidRuntime(254):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
07-20 20:19:19.811: E/AndroidRuntime(254):  ... 11 more
我的舱单

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


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

    <application
        android:allowBackup="true"
        android:icon="@drawable/icon"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.thepasics.Main"
            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="Menu"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="com.example.thePasics.MENU" />

                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
         <activity
            android:name=".TutorialOne"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="com.example.thePasics.TUTORIALONE" />

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

</manifest>
这是menu.java

package com.example.thepasics;

import android.app.Activity;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class menu extends Activity{

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        //Button sound
        final MediaPlayer buttonSound = MediaPlayer.create(menu.this, R.raw.buttonsound);

        //Setting up button references
        Button tut1 = (Button) findViewById(R.id.button1); 
        Button tut2 = (Button) findViewById(R.id.button2); 

        tut1.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                buttonSound.start();
                startActivity(new Intent("com.example.thepasics.TUTORIALONE"));

            }
        });

        tut2.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                buttonSound.start();
                startActivity(new Intent("com.example.thepasics.TutorialOne"));

            }
        });
    }

    @Override
    protected void onPause() {
        // TODO Auto-generated method stub
        super.onPause();
    }


}
第三个是TutorialOne.java

import android.app.Activity;
import android.graphics.Typeface;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.TextView;

public class TutorialOne extends Activity implements OnCheckedChangeListener{

    TextView textOut;
    EditText textIn;
    RadioGroup gravityG, styleG;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.tutorial1);
        textOut = (TextView) findViewById(R.id.tvChange);
        textIn = (EditText) findViewById(R.id.editText1);
        gravityG = (RadioGroup) findViewById(R.id.rgGravity);
        gravityG.setOnCheckedChangeListener(this);
        styleG = (RadioGroup) findViewById(R.id.rgStyle);
        styleG.setOnCheckedChangeListener(this);
        Button gen = (Button) findViewById(R.id.bGenerate);

        gen.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                textOut.setText(textIn.getText());

            }
        });

    }

    @Override
    public void onCheckedChanged(RadioGroup group, int checkedId) {
        // TODO Auto-generated method stub
        switch(checkedId){
        case R.id.rbLeft: 
            textOut.setGravity(Gravity.LEFT);
            break;
        case R.id.rbCenter: 
            textOut.setGravity(Gravity.CENTER);
            break;
        case R.id.rbRight: 
            textOut.setGravity(Gravity.RIGHT);
            break;  

        case R .id.rbNormal:
            textOut.setTypeface(Typeface.defaultFromStyle(Typeface.NORMAL), Typeface.NORMAL);
            break;
        case R .id.rbItalic:
            textOut.setTypeface(Typeface.defaultFromStyle(Typeface.ITALIC), Typeface.ITALIC);
            break;
        case R .id.rbBold:
            textOut.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD), Typeface.BOLD);
            break;

        }



    }

}
我的3个xml文件是splash、tutorial1和main

这是main.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:background="@drawable/backgroundwithoutericapp"
    android:orientation="vertical" >

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:text="Choose a function" />

    <Button
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Button1"
        android:textSize="25dp"
        android:textStyle="bold" 
        android:id="@+id/button1"/>

    <Button
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Button2"
        android:textSize="25dp"
        android:textStyle="bold" 
        android:id="@+id/button2"/>
</LinearLayout>

第二个是splash.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" 
    android:background="@drawable/background">


</LinearLayout>

第三个是tutorial1.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:background="@drawable/tutorialonebackground"
    android:orientation="vertical" >

    <EditText
        android:id="@+id/editText1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:weightSum="2" >

        <TextView
            android:id="@+id/tvStyle"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:gravity="center"
            android:text="Style"
            android:textSize="25dp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/tvGravity"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:gravity="center"
            android:text="Gravity"
            android:textSize="25dp"
            android:textStyle="bold" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:weightSum="2" >

        <RadioGroup
            android:id="@+id/rgStyle"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:orientation="vertical" >

            <RadioButton
                android:id="@+id/rbNormal"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Normal" />

            <RadioButton
                android:id="@+id/rbItalic"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Italic" />

            <RadioButton
                android:id="@+id/rbBold"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Bold" />
        </RadioGroup>

        <RadioGroup
            android:id="@+id/rgGravity"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:orientation="vertical" >

            <RadioButton
                android:id="@+id/rbLeft"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Left" />

            <RadioButton
                android:id="@+id/rbCenter"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Center" />

            <RadioButton
                android:id="@+id/rbRight"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Right" />
        </RadioGroup>
    </LinearLayout>

    <TextView
        android:id="@+id/tvChange"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:text="Type in Text and Press the Button Below" />

    <Button
        android:id="@+id/bGenerate"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Generate" />

</LinearLayout>

您的菜单类实际上称为“菜单”,而不是“菜单”


尝试在整个应用程序中将
“com.example.thePasics.MENU”
更改为
“com.example.thePasics.MENU”

您在manifest.xml中指定了错误的类名

替换

<activity
            android:name="Menu"
            android:label="@string/app_name" >


您的清单和菜单活动不匹配。你的舱单上有

<activity
    android:name="Menu" ...

我只查看了您的日志:

07-20 20:19:19.801: W/dalvikvm(254): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
07-20 20:19:19.811: E/AndroidRuntime(254): FATAL EXCEPTION: main
07-20 20:19:19.811: E/AndroidRuntime(254): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.thepasics/com.example.thepasics.Menu}: java.lang.ClassNotFoundException: com.example.thepasics.Menu in loader dalvik.system.PathClassLoader[/data/app/com.example.thepasics-2.apk]

由于您的
com.example,您的应用程序正在崩溃。找不到asics.Menu
,请使用
android:name=“.Menu”
而不是
android:name=“Menu”

非常感谢!现在它的工作,我可以继续与教程@EricOstring-如果答案有助于解决问题,请务必接受。祝你好运谢谢,我发现了我的错误。这对我帮助很大,现在我可以继续从教程中学习了。非常感谢。我这样做了,现在它的工作,因为它应该。现在我可以继续学习教程了
  <activity
                android:name="com.example.thepasics.menu"
                android:label="@string/app_name" >
<activity
    android:name="Menu" ...
07-20 20:19:19.801: W/dalvikvm(254): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
07-20 20:19:19.811: E/AndroidRuntime(254): FATAL EXCEPTION: main
07-20 20:19:19.811: E/AndroidRuntime(254): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.thepasics/com.example.thepasics.Menu}: java.lang.ClassNotFoundException: com.example.thepasics.Menu in loader dalvik.system.PathClassLoader[/data/app/com.example.thepasics-2.apk]