Android 1.6的应用程序在模拟器上运行出现如下错误:
The application XXX has stopped unexpectedly.Please try again代码是我从android的一篇文档中复制的,居然会有运行错误,代码如下:
Sudoku.java文件:
package org.example.sudoku;import android.app.Activity;
import android.os.Bundle;
import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;public class Sudoku extends Activity implements OnClickListener {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        // Set up click listeners for all the buttons
        View continueButton = findViewById(R.id.continue_button);
        continueButton.setOnClickListener(this);
        View newButton = findViewById(R.id.new_button);
        newButton.setOnClickListener(this);
        View aboutButton = findViewById(R.id.about_button);
        aboutButton.setOnClickListener(this);
        View exitButton = findViewById(R.id.exit_button);
        exitButton.setOnClickListener(this);
    }
    public void onClick(View v) 
    {
     switch (v.getId()) 
     {
         case R.id.about_button:
             Intent i = new Intent(this, About.class);
             startActivity(i);
         break;
         // More buttons go here (if any) ...
     }
    }
}About.java文件
package org.example.sudoku;import android.app.Activity;
import android.os.Bundle;public class About extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.about);
    }
}AndroidManifest.xml文件:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="org.example.sudoku"
      android:versionCode="1"
      android:versionName="1.0">
    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".Sudoku"
                  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=".About"
                  android:label="@string/about_title">
        </activity>
    </application>
</manifest> 
资源文件就不贴了,看了好就没发现是哪里的问题,哪位大虾帮忙分析下啊。

解决方案 »

  1.   

    打开LogCat看看, Exception出在哪里
      

  2.   

    很明显就是抛出异常了啊 , 照LS说的吧
    自己用Log看具体错误在哪了。
      

  3.   

    自己用Log看具体错误在哪了!应该很容易就解决了!
      

  4.   

    看看log再說吧,複製的代碼也會因為配置問題而出錯的。
      

  5.   

    thread exiting with uncaught exception (group=0x4001aa28)
    错误是知道啊,就是不知道如何去定位。哪位大虾指点一下。
      

  6.   

    应该是找不到activity吧,
    <activity android:name=".About"
                android:label="@string/about_title">
        <intent-filter>
          <action android:name="android.intent.action.MAIN" />
          <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>另外定位error请参照ddms,具体使用方法:http://www.moandroid.com/?p=638