After finally getting the Android Facebook SDK to properly import thanks to this, I found that eclipse does not recognize the override of onclick in FbDialog.java:
mCrossImage.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
mListener.onCancel();
FbDialog.this.dismiss();
}
});
Nor does it recognize the overrides of onServiceConnected and onServiceDisconnected in the TokenRefreshServiceConnection implementation of ServiceConnection
#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's no point in
// keeping the binding open.
mAuthActivity.unbindService(TokenRefreshServiceConnection.this);
}
All three methods say, in the warning, that the method must override a superclass method. I have not modified the code at all yet. I checked that Eclipse recognizes the types as the same ones in the respective superclasses, and I have tried pressing control-shift-o to organize the imports, which was a fix suggested in this answer for a similar problem.
These overrides are part of the SDK, not any separate project. I set up the project to use Android SDK 2.2 as was shown on Facebook's instructions, and 4.0.3, which should be, theoretically, compatible with all previous versions. I have yet to get Facebook's own code to work. As a side note, is there a jar I can use instead? It would make this much easier.
Guessing your Project Properties -> Java Compiler Compiler compliance level is set to 1.5, not 1.6 (or higher).
Change this.
Why is javac failing on #Override annotation
The lazy, fast and easy fix is to remove the #Override annotations. The correct fix is to check that the project compiles to Java 1.5 or above, to use "fix project properties" from Eclipse, and possibly to check that the Facebook library project uses the same Android SDK for compiling against, as your project.
Related
I moved my Eclispe project to Android Studio, but it outputs a lot of deprecated errors when built. I tried some methods, but they don't work.
Try placing this at the top of the methods:
#SuppressWarnings("deprecation")
Example
#SuppressWarnings("deprecation")
public void testMethod(){
...
}
For a brief explaination go to this link:
https://stackoverflow.com/questions/7397996/what-is-suppresswarningsdeprecation-and-unused-in-android
Update:
It seems that there is also some known issues with deprecations. You might want to read this for more info:
stackoverflow.com/questions/26921774/how-to-avoid-deprecation-warnings-when-suppresswarningsdeprecation-doesnt
I want to creat an app login and upload photo to facebook..
I downloaded facebook android sdk at : https://github.com/facebook/facebook-android-sdk
I also done as that tutorial: https://developers.facebook.com/docs/mobile/android/sso/
But in step 1: when i create a facebook sdk project,it display error at Facebook class in part:
#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's no point in
// keeping the binding open.
applicationsContext.unbindService(TokenRefreshServiceConnection.this);
}
Image error:
http://nn7.upanh.com/b1.s28.d1/249400dcc8b86b740a9fab6679a809e3_45509157.project2.png
I don't resolve this problem so I can't do next step.:(
Can you help me.
You will need to do two things:
link the facebook sdk to your project.
link the com_facebook_android library to your project.
You might also need to clean your project, and perhaps use the "fix project properties automatically" tool. Perhaps even restart eclipse if you still have errors.
I had many Android projects that were working fine in my old pc. now, when I tried to re import them, they are not running. Problem is that onClickListener is not working. Wherever there is onClick method, it throws an Error:
The method onClick(View) of type new View.OnClickListener(){} must override a superclass method
My actual method is :
myBtn.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
//my code
}
});
What would be the problem?In every project wherever there is onClick method it shows the same.
Using my supehuman guessing powers I assume that you are using eclipse. Eclipse projects are not portable between machines as they contain absolute paths ( but that does not stop developers from checking them in into source control system ).
Your options are:
recreate eclipse project from sources
create maven build with android plugin and make it create you an fresh eclipse project
spring 150 bucks and buy you license for IntelliJ IDEA ( or just use free community edition which also has android plugins )
simply remove all #Override annotation above the onClick() methods
Goto project menu and clean the project.
Option 1: Simply remove all #Override
Option 2: In Eclipse -> Window -> Preferences -> Java -> Compiler, set "Compiler compliance level" to 1.6 or higher.
I've looked and looked, but Eclipse (3.6, with the 2.2 Android SDK) just won't do anything with the AIDL file I created. The AIDL file is in the same place as the other source, following the Java style. I've read that Eclipse should just generate the stub for the interface declared in the AIDL file, but it doesn't appear in the gen folder, nor anywhere else i've seen, and the project doesn't build because the interface specified in the AIDL isn't found. I suspect i'm doing something silly or not understanding something, but as much as i've looked and tried, I still don't get it and Eclipse still fails.
My AIDL:
package com.example.helloandroid;
interface HOSPlayerInterface
{
public void playURL(String url);
public boolean pause();
public boolean resume();
public void stop();
}
... and said AIDL lives in the com/example/helloandroid directory. Eclipse isn't recognizing it, highlighting syntax, running AIDL, etc. I'm at a loss. The Android plugin is installed and working, as i'm able to build and run simple Android projects that don't require AIDL. Any help would be appreciated.
Just remove all "public" access modifier before method declaration. The following code works in my project.
package com.example.helloandroid;
interface HOSPlayerInterface {
void playURL(String url);
boolean pause();
boolean resume();
void stop();
}
If the aidl file can not get compiling in Eclipse, delete "gen" folder and rebuild the project.
Any build errors? The IDE might exit prior to compiling your .aidl-file due to parse errors in XML or similar.
I reinstalled my computer and tried now to import my Android project into the workspace.
(File -> Import -> General -> Existing Project into Workspace)
But now I have got a strange error.
bNormal.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
gotoNextQuestion();
}
});
In the second line (#Override) eclipse always tells me there is an error:
/* Multiple markers at this line
- implements android.view.View.OnClickListener.onClick
- The method onClick(View) of type new View.OnClickListener(){} must override a superclass Method */
This happens everywhere, where #Override is used.
I already tried to Android-Tools -> Fix Project Settings and Project -> Clean.
I hope somebody can help me with this strange problem.
Thanks, Mark
It is because the language level is set to 5.0. Change it to 6, and all will work fine. Don't know where to set it eclipse, but in Idea it's File - Project Structure - Project Language level
It happens because OnClickListener is an interface and in 5th Java #Override can not be applied to a method implementation.
Your android SDK is probably not in the same path. Fix that in your eclipse settings.