My Eclipse installation suddenly stopped showing import suggestions. If I type a class name that isn't in the current package, autocomplete works fine and shows the class, but after picking from the drop-down, the class name is highlighted as an error with the message "MyClass cannot be resolved to a variable". This error shows no Quick Fix suggestions. However, if I manually add the relevant import statement at the top of the file, the code compiles and runs fine.
I've checked my build path and everything appears to be in order -- and like I said, the code runs when I hand-jam the import statement -- but losing automatic importing is really slowing me down. Any idea what could have gone wrong? It worked fine last week!
ETA: Another note, if it helps: F3 still opens the class declaration, so Eclipse clearly knows what I "mean", even without the import statement.
Also also: Things that have not helped:
Clean all projects
Restarting Eclipse
Restart computer
Delete .metadata from workspace, re-import project
Start new Java project, re-link source folder, re-add dependencies (not using Maven, but that's not my choice)
Thanks for all the help, everybody, but this turns out to have been a case of a broken Eclipse install.
I still haven't figured out exactly how or what was broken, but I tried to make a new project with a single "Hello World" class. The New Class wizard errored out with "Creation of element failed" in the class org.eclipse.wst.jsdt.internal.core.dom.rewrite.ImportRewriteAnalyzer. Once I hit "internal errors" in Eclipse, I gave up and installed a fresh Eclipse from a new download.
With a new Eclipse, I got my Quick Fix suggestions back, as well as automatic imports. I guess in future I'll try reinstalling Eclipse before I go looking for solutions to obscure errors like this :-/
These kind of situations can occur if your workspace went into a bad state or eclipse was unable to properly save state during last exit of workspace.
Try Project > Clean and clean all projects and rebuild all. See if this helps.
Clean all your projects. Then update Eclipse. Then restart of Eclipse. Then restart your development PC.
This happens to me sometimes too, I follow these steps and the problem always goes away.
If none of the other answers works, one brute force suggestion which sometimes resolves weird issues like this would be:
Close your Eclipse
Delete the .metadata folder inside your Workspace folder
Restart Eclipse
Note: This way you're going to lose all your workspace configuration. I advise you to backup it first in case it doesn't works.
i imported project that alredy works using SVN in eclipse , i needed to gain knowledge about that one, but unfortunetly i can't even build it. Whenever i build it i get multiple errors that are caused by
The import XXX.bl.* cannot be resolved
There are around 20 imports but only the ones from XXX.bl.* dont work. I will type you what i already tried to do:
Project -> Clean..
Adding XXX.bl in build path
Deleting and adding this imports
Changing to Java 1.6
Delete/Add JRE Library and adding Alternate JRE's
Ticking in Project Facets Java and Utility Mode (for no reason i read somewhere about it)
importing by clicking on "errored" viarable/class "import XXX.bl.*". Problem was solved but only until i Re-build/Clean project.
Closing projects, cleaning, open projects, cleaning
The weirdest thing is that when i type XXX.bl. and then click CTRL + Space it actually autofill this imports with correct names.
Im using JDK (Java EE 6 SDK Update 1 (with JDK 6 U23)).
I spent alot of time in order to search for a fix but nothing helpt so i figure out meaby if i create question here by myself and inform you what i already did you will be able to help me somehow.
Sorry for my pretty bad english, and thanks in advance!
codes are in 'sync', imports are in XXX.bl
I know this question has been asked before and I have seen a plethora of solutions out there, yet none seem to work for me. I was able to build my apk without issues until this error started cropping up. I have tried cleaning my project, removing it from the workspace and reimporting it, removing "Java Builder" from my Builders for the project, building the project manually, reordering my java build path. I have no visible compiler issues and no problems exist in my workspace.
I did experience this issue before and solved it once by removing the project form my workspace and re-importing it and another time I solved it by removing "Java Builder" from my java build path. None seem to work this time. I currently have most of the settings set back to default (i.e. java build is checked again).
I am running windows 7 (64 bit) and using jdk1.6.0_21 via Eclipse 3.6.
Any suggestions would be greatly appreciated as I have lost loads of development time troubleshooting this already.
[Update] My locale is English & I have tried removing the debug.keystore, United States as related to issue 834
Please follow these steps; this might help you out:
Right-click your app project and go to Properties
Select Android from left-hand side list
Uncheck the "Is Library" checkbox
If your app project relies on library projects which are in your workspace, those of course need to have the "Is Library" box checked.
deleting the R.Java file in /Gen folder did the trick for me
I tried all the above solutions. but it didn't work.
The solution was to restart eclipse !!!!!!!
hope this will help someone :)
In my case this problem started after eclipse updated the plugin with the v4.0 API release. I fixed it by going to the main preferences for Eclipse and under Android->Build uncheck 'Skip packaging and dexing until export or launch'
Note: if you eclipse gives you the Unknown Command 'crunch' error then follow this post
I've tried to gather the best of other peoples answers into a step by step list of things to try in order:
Check the project is not set as a library:
Go to Project->Properties
Select Android from left-hand side list
Uncheck the "Is Library" checkbox
Clean and rebuild the project - this should delete and recreate the entire gen folder, including the R.java file mentioned in some peoples answers
Check eclipse and all the Android plugins are up to date
Close the project, exit Eclipse, reopen eclipse, reopen the project.
Go to Java Build Path > Projects and check for any incorrect project dependencies
Go to the main preferences for Eclipse and under Android->Build uncheck 'Skip packaging and dexing until export or launch'
Check JAVA_HOME is set correctly. Follow the steps in this article
If you complete the above list, and still haven't solved the issue, please leave a comment, or if you find something else that works, feel free to edit the answer and add your thing in.
Delete the project from your workspace & import again.
This worked for me.
Can't believe similar issue has been there since 2008.
http://code.google.com/p/android/issues/detail?id=834.
i'm no expert, but eclipse on Windows, doing android apps, refuses to create the default.properties file (in the app root directory). I've just copied one from another app and it works fine. Simple contents, for Android 2.2 project it just says (ignoring comments):
target=android-8
fwiw
I was having the same issue as the OP except that all these suggestions did not work. I found a solution for me.
Make sure that "Skip packaging and dexing until export or launch." is selected.
Go to Window -> Preferences -> Android -> Build. Just make sure that option is selected and apply.
I know this does not make a lot of sense, but having it unselected was giving me this error and with it selected it goes away and the apk is installed.
I am using the auto generated ant build script from android and ONLY using it as my build process in eclipse. I am not using any other build methods.
I figured it out. I was referencing JavaSE-1.5 and using JDK 1.6. I changed it to use 1.6 and that appears to fix it.
Seems like through my research that is an overloaded error message that covers a lot of error cases.
I just fixed this by reselecting a default JRE for the execution environment (JRE6 for JavaSE-1.6 in my case). It got unchecked for some reason.
This fixed my problem. I kept getting the console error in eclipse "Could not find com_android_vending_licensing.apk" and even though it didnt seem to effect the way my app ran, it was annoying. So going into the com_android_vending_licensing project properties and unchecking the "is library" option, building the project to produce the needed apk and then going back into the com_android_vending_licensing project properties and re checking the "is library" check box fixed the problem.
Run Eclipse as "Administrator" and then import the project.
None of these things worked for me. I'm trying to access native code through the jni, first with NDK samples. What I found was the build won't run if jarlist.cache is not present in the project bin directory. If I copy one from another project to that location (may need to refresh to see the folder in Eclipse), build works every time.
Clean the project and it will do. Sometimes it happens unknowingly but keep trying to solve using diff methods.
I had somehow done a Run configuration as a Java application instead of a Android.
the problem for me was I was trying to use IBM RAD which appears to not work properly for this, I installed Eclipse and now have a different error but I should be able to get past it
On my machine (Windows7, 64bit) I could fix this by setting my execution environment to a 32bit variant of the jdk (I used 1.6.0_23). And I tried a lot of things before...
SHA1's answer did it for me: after updating to the latest sdk/adt, my project refused to build an apk; unchecking the option resolved the issue.
I don't know if the update checked this, or if it was checked before but the new adt screwed things up, but things work again now :)
In my case this worked :
Delete R.Java file in /Gen folder
+
Delete all "R.Android" imports that Eclipse added to some of my java classes !!!
and rebuild the project.
remove -- R.java -- Clean the project and run again.. this worked for me ..
Find the project's folder in your system, enter it's Properties via context menu and deselect "Read only" option. Worked in my case.
This seems to be the source of the problem in many cases, moreover some solutions up there base on copying/rewriting the files in the project what makes them non-read-only.
This is caused by JAVA_HOME not being set correctly. It can be easily resolved by following the steps in this article.
Mine was caused by this problem (incompatibility between ADT and SDK), and was fixed thus:
Eclipse > Help
Install New Software
Add 'https://dl-ssl.google.com/android/eclipse/' to 'Work With'
section and press enter
After developer tools appears on the list, check it and click Next
Restart eclipse once download is finished
I my case, I had to switch from API 21 to API 19, clean and build and everything was fine again. I am using a Mac and apparently API 21 is not fully supported on Yosemite.
This question already has answers here:
Another R.Java file missing [duplicate]
(5 answers)
Closed 9 years ago.
I opened an android application project called Test Canvas and later cleaned it by
Project > Clean ...
'Bulid Automatically' option was ticked.
Then the R.java file was deleted and it did not regenerated.I tried all the other options mentioned in the questions of stackexchange.But the R.java file remained missing.
One answer said that R.java generation fails because of errors in .xml files.But there were no errors.I'm 100% sure.
Then i created a new android application project which cannot have any issues in xml files.
When i created the new project it didn't came with the R.java file. I tried cleaning and building with different combinations.It still doesn't work.
I am using eclipse Helios
Android API 15
Android SDK Manager Revision 22
JDK 7U25
Can any one help me on this please?
I understand you have tried cleaning the project. What I would like you to do is Build the project and check the console for any errors.
The R.java also doesn't gets generated if the your project contains errors and these errors are clearly mentioned in your console.
Have a look and see if you can resolve your problem.
Try the following
Close and Reopen the project
Ensure your project folder has 777 rights
Use a later version of Android, that triggers a clean build
Check Problems tab, sometimes errors are not shown on the project files/folder, but a error shows up in this tab
Check top to see the amount of memory you have left, sometimes OOM screws things up
Please use a more later version 1.5 is like decades old
Try this.
Open the properties of your Project
Go to the Android Build target of your Application
Just change the from the currently checked one to another version(can be anything, but one that is supported to at least the minSDK declared in the Manifest)
Do a clean build, if your Project has no issues like in your resources like hyphens in draw able names,unrecognized strings,missing dimension values etc ... your Project should generate the R package with the R class
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Developing for Android in Eclipse: R.java not generating
Im using Ubuntu 12.04 with Eclipse Indigo (I downloaded classic, and it poped up with that on the splash screen, so I guess thats it). I am trying to use the Android SDK with it. I downloaded all the SDK's possible from the interface, then added the Eclipse plugin. I created a project to mess around with Android stuff, and there are two errors. One error I fixed. The other was something like, "R.java does not exist". I Googled it, and found other Stack Overflow questions similar to this one. I made a new one, because all the answers to the other questions didnt work. I tried cleaning my workspace and my project, I tried reinstalling the plugin and the SDK. Nothing worked. Is there anything Im missing to have Eclipse generate R.java? I am also using the 32-bit version of Ubuntu, if that makes a differece.
You failed to actually include any code in your question, so we cannot help to verify whether or not it is correct.
Assuming your Java code is correct, most likely your cause is an error in a resource or your AndroidManifest.xml file that is preventing R.java from being regenerated. To figure out what is going on:
Look for red X marks in the Package Explorer for resources or the manifest
Look in the Console for error messages
Look in the Problems view for error messages
Try the following to see if it helps
right click on the project
select Android tools
select Fix Project Properties