Tuesday, October 25, 2011

How to solve Must Override a Superclass Method Error

Ever import some Android sample code into eclipse and get the dreaded  "Must Override a Superclass Method Error"?
In this blog post I am going to explain the source of the problem and how to fix it.

You might receive an error like this:
The method onClick(View) of type new View.OnClickListener(){} must override a superclass method Java Problem





The Source of the Problem: The project was written with a Java JDK Compiler compliance level of 1.6 but your eclipse setting is 1.5.

How to fix the problem: 


Right click on your project and select "properties"
Select "Java Compiler" 
Make sure "Enable project specific settings" is checked
Change the "Compiler compliance level:" to 1.6
Save the changes. 
Now select "Project" > "Clean..." 
Your project should now build without any errors.

Please feel free to post comments or questions. I usually post a reply within a day or two.

53 comments:

Anonymous said...

thanks a lot for this post, saved me some time.

Anonymous said...

Great thanks.

Nick said...

Thank you!

Anonymous said...

Thank you so much, you saved my life!

IamStalker said...

Hi what is the style of your eclipse and how can i get it?

Greg Zimmers said...

I created it. I also am sharing it. Here is my blog post about my dark color theme and a link to download the import file.

http://androidcodemonkey.blogspot.com/2011/04/eclipse-dark-color-theme.html

Anonymous said...

Excellent help

Anonymous said...

I LOVE YOU

madsravn said...

Thank you! Have been looking all over for this. Was kinda hard to find :)

Anonymous said...

Excellent
Thank you

Anonymous said...

Nice thank you....

Anonymous said...

Thank you. This helped me out tremendously.

Anonymous said...

This is very helpful! Thanks! :D

cz said...

This saved my ass. Thanx a lot.

Anonymous said...

Thanks a lot. Saved a lot of time. :-)

TimothyOnline dotnet said...

Kicked my errors out the front door. Thanks, buddy!

Sagar said...

Hello,
Thanks a lot, Its working for me.

Anonymous said...

Thank you!!! You have saved one more soul today...

Anonymous said...

saved me a bunch of frustration! Thanks!

Anonymous said...

Thanx!

Anonymous said...

Super.......

afnan khan said...

A lat of thanks

Anonymous said...

Great! Thanks a lot. Saved a lot of time

Anonymous said...

Thanks a lot!!!

Anonymous said...

Thanks! Helped a lot :)

Anonymous said...

thanks a lot

freedownloadcore said...

amazing. thanks. it works now :)

chris said...

This helped me greatly!

Anonymous said...

Great Job man ...
Helped me a lot :)

Anonymous said...

thanks!-angeles jesus

John Paul Manoza said...

If you set the Compiler to 1.6.and still you get this error. Try to check your imports. Eclipse always try to do this 'import android.content.DialogInterface.OnClickListener' instead of the doing this -> 'import android.view.View.OnClickListener'. That solves my problem.

Unknown said...

Thanks - had this exact problem - love the quick fix

Anonymous said...

Amazingly helpful thank you

Anonymous said...

Thanks much !!!

Anonymous said...

Thanks Greg.

Anonymous said...

THAAAAANNNNKKKKSSSS!!!!!!!!!!!!!!!!

Anonymous said...

Thanks a lot! :)

Anonymous said...

Thank's mate!
That saved my laptop from a rather violent punch.

John Coogan said...

Thanks a ton! Saved me a ton of time!

Unknown said...

thanks for the post

Anonymous said...

Thank you. Thank you very much.

Anonymous said...

Thanks a lot!

Anonymous said...

Sorry to be negative but this didn't work for me. Still getting told to remove @Override. Any other suggestions ?

Anonymous said...

Just found the solution on another site. After setting Compliance Level to 1.6 and BEFORE running Clean, it is essential to uncheck Project > Build Automatically.

Anonymous said...

Awesome Solution...

Kennedy Mwenda said...

Great

Anonymous said...

Gracias!
Thanks!

Anonymous said...

Thanks for this nice post. Saved me a lot of time.

Ranjeet Shukla said...

thanks for help

Chang bui thi said...

This is also a very good post which I really enjoyed reading. It is not everyday that I have the possibility to see something
Signature:
i like play games friv online and play games2girls Download baixar facebook

Frozen Juegos said...

I am happy to find this post very useful for me
Signature:
Jugar juegos de frozen en línea gratis, los nuevos de princesa de Disney juegos frozen - la princesa encantadora y linda. Divertirse frozen!

Facebook Descargar said...

Thanks for sharing the information. It is very useful for my future. keep sharing
Signature:
download descargar facebook gratis para Android celular and download free descargar facebook apk en español, descargar facebook plus , descarga facebook

Whatsapp Descargar said...

Great post,Thanks for providing us this great knowledge,Keep it up.
A good blog.
Signature:
download free descargar whatsapp plus gratis and download whatsapp baixar online and descargar whatsapp , baixar whatsapp gratis

Post a Comment