Android Android SDK source will not compile using Eclipse Indigo

Finally, after the Android Facebook SDK correctly imported thanks to this , I found that eclipse did not recognize the onclick override in FbDialog.java:

mCrossImage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mListener.onCancel(); FbDialog.this.dismiss(); } }); 

Nor does it recognize the onServiceConnected and onServiceDisconnected overrides in the TokenRefreshServiceConnection ServiceConnection override

 @Override public void onServiceConnected(ComponentName className, IBinder service) { messageSender = new Messenger(service); refreshToken(); } @Override public void onServiceDisconnected(ComponentName arg) { serviceListener.onError(new Error("Service disconnected")); // We returned an error so there no point in // keeping the binding open. mAuthActivity.unbindService(TokenRefreshServiceConnection.this); } 

All three methods say in a warning that the method should override the superclass method. I have not changed the code yet. I checked that Eclipse recognizes the types as the same in the corresponding superclasses, and I tried pressing control-shift-o to organize the import, which was fixed in this answer for a similar task.

These overrides are part of the SDK, not a separate project. I configured the project to use the Android SDK 2.2, as shown in the Facebook instructions, and 4.0.3, which should be theoretically compatible with all previous versions. I have not yet received my own Facebook code to work. As a note, is there a jar that I can use instead? That would make it a lot easier.

+6
source share
2 answers

Guess your project properties -> Java Compiler Compiler. The compiler's compliance level is set to 1.5, not 1.6 (or higher).

Change it.

Why javac doesn't work with @Override annotation

+15
source

A lazy, quick and easy fix is โ€‹โ€‹to remove @Override annotations. The correct fix is โ€‹โ€‹to verify that the project compiles in Java 1.5 or higher, to use the โ€œfix project propertiesโ€ from Eclipse and possibly verify that the Facebook library project uses the same Android SDK to compile as your project.

+2
source

Source: https://habr.com/ru/post/907813/


All Articles