我的程序在我的Android模擬器立即崩潰,我收到這在Eclipse控制檯:如何解決Android上的NullPointerException?
java.lang.NullPointerException
at com.android.ddmlib.Client.sendAndConsume(Client.java:572)
at com.android.ddmlib.HandleHello.sendHELO(HandleHello.java:142)
at com.android.ddmlib.HandleHello.sendHelloCommands(HandleHello.java:65)
at com.android.ddmlib.Client.getJdwpPacket(Client.java:671)
at com.android.ddmlib.MonitorThread.processClientActivity(MonitorThread.java:317)
at com.android.ddmlib.MonitorThread.run(MonitorThread.java:263)
我怎麼能解決什麼是引發此消息?我是Eclipse和Android的新手。
,當我嘗試推出一個按鈕,對話框的程序完全崩潰,並回到這裏指的是:
@Override
protected Dialog onCreateDialog(int id) {
Dialog dialog;
switch (id) {
case TIME_DIALOG_ID:
return new TimePickerDialog(this,
mTimeSetListener, mHour24, mMinute, false);
case POWER_OFF_OPTIONS:
AlertDialog.Builder builder;
AlertDialog alertDialog;
Context mContext = getApplicationContext();
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.options,
(ViewGroup)findViewById(R.id.relativeLayout1));
//Capture view elements
mChkAudio = (CheckBox) findViewById(R.id.chkAudio);
mChkBluetooth = (CheckBox) findViewById(R.id.chkBlueTooth);
mChkNetwork = (CheckBox) findViewById(R.id.chkNetwork);
mChkWifi = (CheckBox) findViewById(R.id.chkWifi);
mBtnOK = (Button) findViewById(R.id.btnOK);
mBtnOK.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
DismissPowerOptions();
}
});
builder = new AlertDialog.Builder(mContext);
builder.setView(layout);
alertDialog = builder.create();
//return alertDialog;
default:
dialog = null;
}
return dialog;
}
任何事情之前你HandleHello Activity類檢查線142。 – papachan 2011-04-13 17:21:02
我希望看到關於**如何在Android中解決**問題的答案。我不做Android開發 - 但是有什麼工具(例如調試器或靜態分析器或方法論)可用於在Android平臺上以可重複的方式找出哪些問題? – 2011-04-13 17:36:59
我有一個警告,但沒有錯誤:靜態字段AudioManager.STREAM_SYSTEM應該以靜態方式訪問 – Andrew 2011-04-13 19:13:46