• Register
Welcome to Kodlogs, programming questions and answer website.
0 votes
27 views

Problem :

I am getting bellow error while learning android and trying to make a semi-useful app.

java.lang.illegalstateexception: could not execute method for android:onclick

by (6.9k points)  

1 Answer

0 votes

Solution:

This bellow line is throwing an NPE, producing an IllegalStateException in the exception chain:

int stopPortRange = Integer.parseInt(stopPort.getText().toString());

as you don't initialize stopPort (or startPort) in your onCreate method. You should have something like:

stopPort = (EditText) findViewById(R.id.stop_port_field);

The statement

EditText stopPort;

simply declares the variable which is null by default. Only instances that have been instantiated can have their methods invoked.

Further Readings:

https://github.com/printdotio/printio-android-sdk/issues/162

by (30.3k points)  
edited by
...