Skip to content Skip to sidebar Skip to footer

Java - Android Sdk - Unfrotunately Has Crashed Error

I Have been working on a small app, which can calculate complex numbers for me (division, subtraction, multiplying etc.). I have no apparent compile errors, but when i run the prog

Solution 1:

initialize X1,X2,Y1,Y2 in your onCreate() as Ted Hopp mentioned in his answer and then

change this:

if(xs!="" && xss!="" && ys!="" && yss!="")

to:

if((xs!=null&&!xs.equal(""))&&(xss!=null&&!xss.equal(""))&&(ys!==null&&!ys.equal(""))&&(yss!=null&&!yss.equal("")))

Solution 2:

The problem appears to be here:

Check.setOnClickListener(newView.OnClickListener(){

    String xs=X1.getText().toString();
    String xss=X2.getText().toString();
    String ys=Y1.getText().toString();
    String yss=Y2.getText().toString();

    . . .
}

When this is executing inside onCreate, the fields X1, etc., have not been initialized. Even if it had, the fields would have only the default text, which is probably not what you want. You should move the assignments into the onClick method of the listener. That way you will be working with the current field contents when the onClick method runs.

In the future, please post the text of the logcat output rather than a screen snapshot. Failing that, at least resize the columns and scroll as necessary so we can see the entire text of the logcat messages. And please identify which line(s) in your code are generating the exception.

Post a Comment for "Java - Android Sdk - Unfrotunately Has Crashed Error"