我正在尝试为Android开发一个应用程序,但是我很难跟踪我在此过程中遇到的每个异常的来源和原因。我的代码在一个Activity中运行,如果我的一行导致异常,那么它不是停在那一行并突出显示它,而是将我引入ActivityThread类的代码,这显然是我没有的,所以我得到一个“未找到来源”屏幕。
FloatingPointParser.invalidReal(String, boolean) line: 78
FloatingPointParser.parseDouble(String) line: 276
Double.parseDouble(String) line: 317
Double.valueOf(String) line: 354
TempConActivity.ctof() line: 77
TempConActivity.onClick(View) line: 41
Button(View).performClick() line: 3100
View$PerformClick.run() line: 11644
ViewRoot(Handler).handleCallback(Message) line: 587
ViewRoot(Handler).dispatchMessage(Message) line: 92
Looper.loop() line: 126
ActivityThread.main(String[]) line: 3997
Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]
Method.invoke(Object, Object...) line: 491
ZygoteInit$MethodAndArgsCaller.run() line: 841
ZygoteInit.main(String[]) line: 599
NativeStart.main(String[]) line: not available [native method]
这是我的源代码:
package de.vogella.android.temperature;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.EditText;
public class TempConActivity extends Activity implements View.OnClickListener
{
Button btn;
double text;
double t;
Button btn1;
Button btn2;
RadioButton celsiusButton;
@Override
public void onCreate(Bundle icicle)
{
super.onCreate(icicle);
setContentView(R.layout.main);
btn=(Button)findViewById(R.id.button);
btn.setOnClickListener(this);
celsiusButton = (RadioButton)findViewById(R.id.radio0);
}
public void onClick(View view)
{
switch(view.getId())
{
case R.id.button:
if(celsiusButton.isChecked())
{
ctof();
}
else
{
ftoc();
}
break;
case R.id.button1:
t=(text*1.8)+32;
int length =(Double.toString(t)).length();
CharSequence t1=(Double.toString(t)).subSequence(0,length-1);
EditText et1=(EditText)findViewById(R.id.editText2);
et1.setText(t1);
break;
case R.id.button2:
t=(text-32)/1.8;
int length1 =(Double.toString(t)).length();
CharSequence t2=(Double.toString(t)).subSequence(0,length1-1);
EditText et2=(EditText)findViewById(R.id.editText4);
et2.setText(t2);
break;
}
}
public void ctof()
{
setContentView(R.layout.ctof);
EditText et=(EditText)findViewById(R.id.editText1);
text= Double.valueOf(et.getText().toString());
btn1=(Button)findViewById(R.id.button1);
btn1.setOnClickListener(this);
}
public void ftoc()
{
setContentView(R.layout.ftoc);
EditText et=(EditText)findViewById(R.id.editText3);
text= Double.valueOf(et.getText().toString());
btn2=(Button)findViewById(R.id.button2);
btn2.setOnClickListener(this);
}
}
答案 0 :(得分:0)
如果它试图打开Android源代码,那么它只是意味着异常发生在您安装的断点之前。尝试分析堆栈跟踪并将断点放在异常发生的位置之前。