• Register
0 votes

Problem :

While executing Android code getting below error 
java.lang.illegalstateexception could not execute method of the activity
6 5 3
6,930 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

Bellow line is throwing an Null Pointer Exception, producing an IllegalStateException in the exception chain:

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

As you don't initialize stopPort in your onCreate method. 

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:


9 7 4
38,600 points

Related questions

1 vote
1 answer 6 views
Problem: I’m getting an error in my code . Here’s the logbox: 01-25 20:42:42.139: E/AndroidRuntime(1307): FATAL EXCEPTION: main 01-25 20:42:42.139: E/AndroidRuntime(1307): java.lang.IllegalStateException: Could not execute method of ... (Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.activity_main, menu); return super.onCreateOptionsMenu(menu); } }
asked May 4 Raj Tyagi 15.6k points
0 votes
1 answer 188 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
asked Oct 19, 2019 peterlaw 6.9k points
0 votes
1 answer 28 views
Any suggestions?
asked Jan 4 TeamScript 13.5k points
0 votes
1 answer 6 views
Problem: I am trying to test my ionic app in android studio. It is throwing the below error. Gradle sync failed: Cause: compileSdkVersion is not specified. Any solution for this ? What am I doing wrong. Here is my build.gradle file apply plugin: ... .test:runner:+' androidTestImplementation 'com.android.support.test.espresso:espresso-core:+' implementation 'com.android.support:appcompat-v7:27.+' }
asked May 3 Yeamin 22k points
0 votes
1 answer 82 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 46 views
problem java.lang.illegalstateexception: already managing a googleapiclient with id 0
asked Feb 9 charles mathews 5.5k points
0 votes
2 answers 9 views
Problem: Below is my code. What i am trying to achieve is that i am displaying viewholder inside my Recycler view. Inside view pager i am displaying one fragment and on swipe left i am displaying another fragment. But when i run the app. App is ... id.viewpager); itemView.setOnClickListener(this); } This is what the error is : java.lang.IllegalStateException: Fragment has not been attached yet.
asked May 3 ochena 23.3k points
0 votes
1 answer 190 views
Problem: java.lang.IllegalStateException: Not allowed to start service Intent.
asked Feb 12 Sabbir Hossain 14.6k points
0 votes
1 answer 6 views
Problem: I am unable to understand this problem .. Please suggest me a better solution to solve it .. java lang runtimeexception unable to start activity
asked Apr 21 Ifra 37.2k points
0 votes
1 answer 3 views
Problem: Is there a solution for this? > Java.lang.illegalstateexception: binder has been finalized!
asked 3 days ago Irenka Kiri 17.9k points