android @override 报错解决方案
程序员文章站
2023-12-14 18:18:16
现象: ... java: 1801: method does not override a method from its superclass @override......
现象:
... java: 1801: method does not override a method from its superclass @override...
原因:
eclipse is defaulting to java 1.5 and you have classes implementing interface methods (which in java 1.6 can be annotated with @override, but in java 1.5 can only be applied to methods overriding a superclass method).
就是说java 1.5的编译器默认对父类的方法进行覆盖,采用@override进行说明;但1.6已经扩展到对接口的方法;所以如果还是以java 1.5的编译器来编译的话,会出现错误。
解决方案:
go to your project/ide preferences and set the java compiler level to 1.6 and also make sure you select jre 1.6 to execute your program from eclipse.
java的编译器是1.6版本的,选择编译级别为1.6,但重要的一点是,选择build的android库是1.5的即可,生成的apk程序是可以在1.5内核上跑起来。
解决方法:
在eclipse中 选择window –> preferences –> java –> compiler 选择1.6 ,如果还不可以,在compiler中选择onfigure project specific settings 选择编译器版本为1.6
... java: 1801: method does not override a method from its superclass @override...
原因:
eclipse is defaulting to java 1.5 and you have classes implementing interface methods (which in java 1.6 can be annotated with @override, but in java 1.5 can only be applied to methods overriding a superclass method).
就是说java 1.5的编译器默认对父类的方法进行覆盖,采用@override进行说明;但1.6已经扩展到对接口的方法;所以如果还是以java 1.5的编译器来编译的话,会出现错误。
解决方案:
go to your project/ide preferences and set the java compiler level to 1.6 and also make sure you select jre 1.6 to execute your program from eclipse.
java的编译器是1.6版本的,选择编译级别为1.6,但重要的一点是,选择build的android库是1.5的即可,生成的apk程序是可以在1.5内核上跑起来。
解决方法:
在eclipse中 选择window –> preferences –> java –> compiler 选择1.6 ,如果还不可以,在compiler中选择onfigure project specific settings 选择编译器版本为1.6