开发者

Eclipse can't connect Debugger to my application?

I'm trying to develop an application for Android, but I'm having difficulties tracing the source and cause of each exception I get in the process. My code runs in an Activity, and if a line of mine causes an exception, then rather than stopping on that line and highlighting it, it throws me into the ActivityThread class's code, which apparently I don't have, so I just get a "Source not found" screen.

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]  

and here is my source code:

   package de.vogella.android.temperature;

   import android.app.Activity;
   import and开发者_如何转开发roid.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);

    }
  }


If it tries to open Android source code, than it just means that the exception occurs earlier than breakpoint that you installed. Try to analize stack trace and put the breakpoint right before the place where the exception occurs.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜