我在 android 中设计了一个简单的应用程序,但是当我在模拟器上运行它时,它显示应用程序已停止...我试图找到解决方案并遇到使用断点...但是当我设置断点并调试应用程序时,它显示“找不到源”从 ddms 的角度来看
ActivityThread.performLaunchActivity(ActivityThread$ActivityRecord, Intent).
有人可以在这里建议我现在做什么...
这就是我的日志的样子
02-20 04:28:21.232: D/AndroidRuntime(607): Shutting down VM
02-20 04:28:21.232: W/dalvikvm(607): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
02-20 04:28:21.262: E/AndroidRuntime(607): FATAL EXCEPTION: main
02-20 04:28:21.262: E/AndroidRuntime(607): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.apps/com.example.apps.Act}: java.lang.NullPointerException
02-20 04:28:21.262: E/AndroidRuntime(607): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
02-20 04:28:21.262: E/AndroidRuntime(607): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
02-20 04:28:21.262: E/AndroidRuntime(607): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
02-20 04:28:21.262: E/AndroidRuntime(607): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
02-20 04:28:21.262: E/AndroidRuntime(607): at android.os.Handler.dispatchMessage(Handler.java:99)
02-20 04:28:21.262: E/AndroidRuntime(607): at android.os.Looper.loop(Looper.java:123)
02-20 04:28:21.262: E/AndroidRuntime(607): at android.app.ActivityThread.main(ActivityThread.java:4627)
02-20 04:28:21.262: E/AndroidRuntime(607): at java.lang.reflect.Method.invokeNative(Native Method)
02-20 04:28:21.262: E/AndroidRuntime(607): at java.lang.reflect.Method.invoke(Method.java:521)
02-20 04:28:21.262: E/AndroidRuntime(607): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
02-20 04:28:21.262: E/AndroidRuntime(607): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
02-20 04:28:21.262: E/AndroidRuntime(607): at dalvik.system.NativeStart.main(Native Method)
02-20 04:28:21.262: E/AndroidRuntime(607): Caused by: java.lang.NullPointerException
02-20 04:28:21.262: E/AndroidRuntime(607): at com.example.apps.Act.onCreate(Act.java:16)
02-20 04:28:21.262: E/AndroidRuntime(607): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
02-20 04:28:21.262: E/AndroidRuntime(607): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
02-20 04:28:21.262: E/AndroidRuntime(607): ... 11 more
02-20 04:28:31.283: I/Process(607): Sending signal. PID: 607 SIG: 9
活动课
package com.example.apps;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
public class Act extends Activity {
Rest r=new Rest();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Button save=(Button)findViewById(R.id.save);
save.setOnClickListener(onSave);
}
private View.OnClickListener onSave=new View.OnClickListener() {
public void onClick(View v) {
EditText name=(EditText)findViewById(R.id.name);
EditText address=(EditText)findViewById(R.id.addr);
r.setName(name.getText().toString());
r.setAddress(address.getText().toString());
}
};
}