I have a annoying problem with #Override annotations in Eclipse. Often when i import working projects on a new PC, Eclipse marks some of the #Override annotations as wrong. If i remove the annotations everything is fine and Eclipse also indicates that the methods are overriding the parents methods but adding the Override annotation causes the error again. I am currently working on an Android project so it might be a problem with Android and not with Eclipse..
This is most likely because you are switching between Java 1.5 and Java 1.6. In 1.5 you couldn't mark interface implementations with #Override, but you can in 1.6.
A quick Google search turned up this good explanation of the difference in this annotation between the two versions: http://www.techienuggets.com/CommentDetail?tx=38155
Semantics of #Override is different in
JDK 1.5 and JDK 1.6. In JDK 1.5, the
#Override annotation is not allowed
for implementations of methods
declared in an interface, while they
are allowed in JDK 1.6. For more
information, see:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5008260
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6399361
http://blogs.oracle.com/ahe/?entry=override
It is fact that the description of the
Override annotation was not updated
in the JDK API docs. This has been
reported as a bug:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6501053bugdatabase/view_bug.do?bug_id=6501053
just go to
window -> prefrences -> java -> compiler
and set it to 1.6 as notation starts from 1.6 so if compilence level will less then 1.6 it will gives error
There are a few places where Java Compiler settings are configured.
One way is to Window->Preferences->Java->Compiler->Compiler Compliance Level -> set 1.6 or above.
Another way is right click on the Project->Properties->Java Compiler->JDK Compliance -> Select 1.6 or above.
Also You can unselect "Enable Project Specific Settings" , this will eliminate future JDK compiler compliance errors.
Remove Multiple instances of JDK Versions , unless different projects need them.
Make sure the used Java SDK is up to date and that eclipse use the right SDK version (if you have more than one installed) and treats your Android project with the right SDK version...
Related
I'm trying to use the latest Facebook SDK (4.2 as of today) in an Android project, and I'm using Eclipse (if I'm not mistaken, this version no longer includes an Eclipse project so I had to create one with the included files).
I'm getting the following error message:
[FacebookSDK] Android requires compiler compliance level 5.0 or 6.0. Found '1.7' instead. Please use Android Tools > Fix Project Properties.
Doing Fix Project Properties does nothing. However, when I manually set the project to use 1.6, I get the following error:
'< >' operator is not allowed for source level below 1.7
Any tips on how to fix this?
Thanks
In case this helps anyone, what I did was what's mentioned in this answer:
How to fix '<>' operator is not allowed for source level below 1.7 in 1.6?
Specifically, I left the version as 1.6 and simply entered the class type that is expected in the <>.
So for example, instead of
ArrayList<ModeHandler> handlers = new ArrayList<>();
I would simply enter the class:
ArrayList<ModeHandler> handlers = new ArrayList<ModeHandler>();
hi i want to make QR code scanner to my android app using ZXing library
i already success try it with "Scanning via Intent" method before
now i try different approach
my problem is i always get this error
my step
1. download zxing master from here
2. download jar from repository here
3. import ‘android’ folder from zxing-master in eclipse
4. create libs folder and copy core.jar in there
5. right click in CaptureActivity - properties - java build path - library tab - add core.jar path
i don't know why i still get error after add jar path...
i already try clean project, swith workspace, using latest jar file but still same
any idea?
#update #Nickolai Astashonok
eclipse error
'<>' operator is not allowed for source level below 1.7
i try to change java compiler using 1.7 (default 1.6) by
right click project - properties - java compiler tab
but it's seem my target API not fullfil requirment (my API 15)
how to use ZXing in java compiler 1.6?
Update #Sean Owen
when i changed using java compiler level 1.7 and clean project it's says
Using 1.7 requires compiling with Android 4.4 (KitKat); currently using API 15
i wanna target my aplication runs for ICS (API 15)
i'm not sure if in 'captureActivity androidManifest using minSDK 19' and 'myProject androidManifest using minSDK 15 will be running well
so i guess i better stick with java compiler 1.6
meanwhile i found this link
based on that link i need to use zxing library version 4.5.1 (java compiler 1.6)
because version above using java compiler 1.7
but i can't find any download link to 'zxing library version 4.5.1'
Your question is not clear, but I think the answer is this: the source code indeed requires Java 7. You simply need to set your IDE project to use Java 7. The supplied Maven build already works correctly in this regard. It is not true that API 15 or any other Android API needs Java 6.
I found 4.5.1 but I don't know how to download it! if you figured it out let me know too please.
https://code.google.com/p/zxing/source/browse/?r=2927#svn%2Ftrunk%2Fandroid
I got the same issue and I solve this by doing:
change the java compiler to 1.7 (like what Nickolai Astashonok suggested)
change the target version to 19 (Android 4.4)
Clean the project again, you will see lots of errors removed but there is still some errors related to missing of CameraConfigurationUtils.java
Please go to below link to download and copy the file into your project as per the path suggested.
https://github.com/zxing/zxing/blob/master/android-core/src/main/java/com/google/zxing/client/android/camera/CameraConfigurationUtils.java
Clean the project again, you should be able to clear all the errors and use the sample application in the 'android' folder.
I am newer to Android and receive the error message: "NotificationCompat cannot be resolved to a type"
MinSDK=9, TargetSDK=18,
As of yet, all sources are very vague on how to resolve this issue and simply note: "update the JAR files".
What JARs do I need and where can I find them, so that this issue is resolved?
You need the support library. Here are the instructions on how to download them: http://developer.android.com/tools/support-library/setup.html
I needed to add "android-support-v4.jar" to my project to use the ActionBar.
From the support link (which has been updated)
With the release of Android 9.0 (API level 28) there is a new version of the support library called AndroidX
From the menu: Refactor > Migrate to AndroidX...
You will be prompted to back up your project to a zip. After that, a Refactor Preview will be shown in the console area. You should see a button "Do Refactor".
This will remove the error under the noted conditions. You may find some lines of code now report as deprecated after the refactor.
Sometimes Eclipse gets hung up on this class, and no amount of cleaning and rebuilding will make it recognize that you have, in fact, added the support library and imported the correct class. I don't know why it always happens with this particular class. But the solution is to close and restart Eclipse.
Below code in onClickLinkToDropbox() method in HelloDropboxActivity class of "Hello Dropbox" example in Android Sync SDK show error as
The type android.app.Fragment cannot be resolved. It is indirectly referenced from required .class files.
How can I solve this ? I'm using Android 2.3.3.
mDbxAcctMgr.startLink(this,REQUEST_LINK_TO_DBX);
This seems to be the compiler being unreasonably picky during overload resolution. I see two possible solutions to this:
Build with a later SDK version (11 or later). You only need to change the SDK you use to build (set the target in Eclipse project properties dialog, or target=android-11 in project.properties). You can leave both minimum and target set to 10 in your AndroidManifest.xml, so your app will still be compatible with older versions. In general it should always be safe to build with the latest SDK. You'll get warnings if you use APIs which don't exist in your manifest-defined target.
Work around it by forcing the overload resolution like this:
mDbxAcctMgr.startLink((Activity)this, REQUEST_LINK_TO_DBX);
If you're not already using it, you will also need the Android Support library. In Eclipse, open the context menu on your project and select Android Tools → Add support library... and follow the prompts to add the library to your project.
https://www.dropbox.com/developers/sync/tutorial/android
I tried to import ActionBarSherlock in sub folder external of omnibus v3.8 but I got so many errors (more than 150). Most of them are about override a super class method.
If I remove #Override annotation at the error line, the error is gone. Should I remove it one by one (more than 150 error) ? Is there any shortcut way to remove all errors?
The release of ADT plugin : 18.0.0
JDK : 1.7
Build target : 15
Thanks
The source code that you imported is from http://github.com/commonsware/cw-omnibus. If you read that Web page, you will find instructions for use of that code. If you read those instructions, you will find that:
You need to have your Java compliance level set to 1.6 and
You may need to adjust the ActionBarSherlock project to build with a build target that you have installed, or to install API Level 14 (which, IIRC, is what ActionBarSherlock wants)