Android Development @ override compilation error Solution

Source: Internet
Author: User

From: http://www.oschina.net/question/12_17487

A long time ago my own android game project, today with eclipse re-open reported a bunch of errors, are related to @ override, Google find a solution (http://blog.csdn.net/skylen/archive/2011/02/21/6198699.aspx ):

 

Mbutton1.setonclicklistener (New button. onclicklistener () {@ override public void onclick (view v) {// todo auto-generated method stub mtextview1.settext ("Hi, everyone !! ");}});

The above code reports the following error:

-Implements Android. View. View. onclicklistener. onclick
-The method onclick (view) of type new view. onclicklistener () {} must override a superclass

Find the JDK version. The project attribute is incorrect. ----> the complier compliance level in javacompiler changes 1.5 to 1.6.

That is to say, the Java 1.5 compiler overwrites the method of the parent class by default and uses @ override to describe it; but 1.6 has extended to the method of the interface; therefore, an error occurs if it is still compiled using the Java 1.5 compiler.

The Java compiler is of version 1.6 and the compilation level is 1.6. However, it is important to select the android library of build as 1.5, the generated APK program can run on the 1.5 kernel.

In general, the android SDK version and Java JRE version can be configured and used. The relationship between the two versions should be loose.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.