[Solved] “Method does not override or implement a method from a supertype”


The answer is fairly simple, the @Override tag adds a compile time check to see if a method is overriding a method from a super class.

And since there is no onCreate2() method in any of Android’s Activity classes (here AppCompatActivity), you cannot override it.

You would have to remove the @Override tag to make your code compile, however onCreate2() will never execute. For this please take a look at the Android Activtiy Lifecycle. OnCreate() gets called on creation of the activity and the code that is in the method will be executed at that point.

You cannot just put random methods into a class and think that they’ll be execute. They have to be called from somewhere, in your case onCreate() gets called from its super classes, but onCreate2() will never get called and won’t compile with wrong @Override tag.

1

solved “Method does not override or implement a method from a supertype”