• Register
0 votes
175 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

6 5 3
6,930 points

Please log in or register to answer this question.

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

9 7 4
38,600 points

Related questions

0 votes
1 answer 92 views
92 views
Problem : While executing Android code getting below error java.lang.illegalstateexception could not execute method of the activity
asked Oct 23, 2019 peterlaw 6.9k points
0 votes
1 answer 22 views
22 views
Any suggestions?
asked Jan 4 TeamScript 13.5k points
0 votes
1 answer 106 views
106 views
Problem: java.lang.IllegalStateException: Not allowed to start service Intent.
asked Feb 12 Shovo210 13.9k points
0 votes
1 answer 63 views
63 views
Problem : Now a days I am learning Android Programming. I am facing below error message while trying to implement the logout functionality for the Google Sign-In for the Android: “Caused by: java.lang.IllegalStateException: GoogleApiClient is not ... .getInstance().getClient(); Auth.GoogleSignInApi.signOut(myGoogleApiClient); } I am struggling to find solution on it since yesterday.
asked Feb 27, 2020 mphil 2.3k points
0 votes
1 answer 26 views
26 views
problem java.lang.illegalstateexception: already managing a googleapiclient with id 0
asked Feb 9 charles mathews 5.5k points
0 votes
1 answer 5 views
5 views
Problem: What can I do for this error> com.android.ide.common.process.processexception: failed to execute aapt
asked Mar 19 Azlan2020 2.3k points
1 vote
1 answer 6 views
6 views
Problem : Getting error in sending arraylist of object from adapter to other activity. I wanna send my arraylist from onBindViewHolder method of Adapter to another activity but its is showing null exception error on the Cast Class in writetoParcel Method. Getting Error ... Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference How to send arraylist properly?
asked Mar 31 Shovo210 13.9k points
0 votes
1 answer 1.2K views
1.2K views
Problem : I am trying to learn Android programming also I am trying to develop a very basic weather app. My code works perfectly if I try to enter any valid city name. But I want to use the toast and it shows me the error and also to the ... .nextCleanInternal(JSONTokener.java:116) at org.json.JSONTokener.nextValue(JSONTokener.java:94) at org.json.JSONObject. How can I fix the above error?
asked Feb 14, 2020 mphil 2.3k points
0 votes
1 answer 3 views
3 views
Problem I am in trouble,can anyone help me to solve this "java.lang.illegalstateexception: default firebaseapp is not initialized in this process?"
asked Apr 6 salim1 39k points
0 votes
1 answer 12 views
12 views
Problem: why this happened to me ? any help ! java.lang.illegalstateexception: injectionmanagerfactory not found..
asked Mar 6 Wafa Abu Yousef 6.1k points