int f = Integer.parseInt(first.getText().toString());
int s = Integer.parseInt(second.getText().toString());
int sum = f+s;
res.setText(sum);
You make the classic mistake in your code that you assume all the input data is valid. If there is anything wrong with the text in either first or second, then your code will crash. You need to capture the text first (and you do not need to call toString on an object that returns a string!), and check that it contains a valid number. Once you have done that you can call
parseInt
.
However, the actual exception in this case may be something else. So you need to provide the full details of the exception message, including the line number that it occurs on.