Eclipse shows error when there are none - android

My eclipse project suddenly shows the red cross(for error) , but when I expand the project, the red crosses are not visible anywhere.
I have tried building , cleaning, rebuilding, etc, and all that does not seem to work
There is another weird thing that is happening now. When I choose to build automatically, It shows 'building workspace' on an on(in an endless loop.
I am using eclipse Luna, on windows 7.
Is it possible that its a git problem ?
Under problems, I get the error:
"The container 'Android Dependencies' references non existing library 'C:\myproject\bin\myproject.jar'

As mentioned before- usually if you're working on multiple projects at the same time the compiler has to have one of them being the "focused" project. This can be messed up when you have multiple projects opened at the same time.
If you have honestly done "File -> Refresh" and "Project -> Clean" then i recommend closing each project- hover over each project file, right click, "close project" and then restart eclipse.
If this does not work then i would love to see the actual source code- mostly because if the compiler will not run then it may be a workspace placement issue your actual libraries.
Just let me know if this is helpful or not. Good luck!

Some time I am facing this issues. In this case i follow below steps:
Open your work space folder
goto in your project folder
goto bil folder
delete classes folder
Refersh your project from eclipse (select your project and press F5)
its always help for me. I hope it will work for you.

If it is a gradle project, refresh your gradle project.
Right click on your project -> Gradle -> Refresh Gradle Project.
It worked for me.

Related

Yet Another 'The project was not built since its build path is incomplete'

I have an Android project that I've been happily building for weeks in Eclipse Indigo. I have not changed any settings, libraries, or workspace components, or added or removed any files. A few hours ago I was doing a "Run as" to run my app on a phone and Eclipse did a hard hang. I couldn't even kill it in Task Manager so I rebooted my PC.
Now when I try to build my app I get
"The project was not built since its build path is incomplete. Cannot find the class file for java.lang.Object. Fix the build path then try building this project"
I deleted gen and did a clean and build with the same result. In the project Properties for the build path, in the Libraries tab it shows
Android Dependencies
Android Private Libraries
Unable to get system library for the project.
Any idea what's going on? This Eclipse "build path is incomplete" error is very common but when I search Stack Overflow and Google, most of the cases seem to be related to importing new projects, moving workspaces, changing libraries or other things I didn't do.
Thanks in advance!
I fixed my problem.
I did a File>Switch Workspace and switched to another workspace that had a different project in it. Then I switched back to my original workspace and everything was fine.
So we can add this to the very long list of folk-remedies, nostrums, old-wives-tales, superstitions and other bits of software lore that accompany the various weird bugs that afflict Eclipse. I sure hope Android Studio turns out to be better than this!
This worked for me:
Open project properties > Java Build Path > Libraries.
Select "Unable to get system library..." > Remove > OK.
Open Libraries again > Add Library > "Android Classpath Container" > Next > Finish > OK.
The following worked for me, so I thought I would share.
Restarted Eclipse and ran into the same problem.
Did the following to get my project to build again.
Right click on project inside Package Explorer and Select properties.
Go to Java Build Path.
Click on Libraries TAB
Remove the line that says "Unable to get system library for the project"
select ok.
Then right click on project, and select "Android Tools" -> "Fix Project Properties."
Hope this helps.... eclipse can be a real PITA sometimes.
BTW I "watched" for any changes after the delete and fix, and it looks like
Is removed from .classpath, and then the "Fix Project Properties" adds the line right back.
Clean + Build works after that.
The resolution was to force a resave of the selected projects (and their .classpath files):
Open the project properties
Select Java Build Path > Libraries
Add a new, arbitrary library (to be deleted later) > OK
Wait for the workspace to refresh (or force a refresh of the project)
The error(s) will go away
Remove the dummy library
Try Project-->Clean. Also make sure "Build Automatically" is checked

Importing existing project in other computer gives me errors

I used this method.
File->Import->General->Existing Projects into Workspace, Next Select root directory: /path/to/project Projects-> Select All UNCHECK both "Copy projects into workspace" and "Add project to working sets" Finish
I got a error in all my Classes. In the onCreate method, setContentView(R.layout.main);
The error is:
R cannot be solved to a variable and main cannot be resolved or is not
a field.
Any help is appreciated.
Right click on the project, and take 'android tools', 'Fix Project Properties'.
Then clean the project. If yet not recovered, repeat the steps by configuring the build path by reordering it..
Hope this might help you..! :)
Try Project -> Clean
Maybe it can solve problem
Probaby the R class is not yet generated by SDK. When you open any of your layouts (xml files) change it ( adding a space is enough ;) )and save it, the R class is re-generated with ids of all your elements from layouts. It is common problem when moving projects or checking out from svn. Re-generations of the files in /gen folder is forced when you change layout files. Hope it helps
Well I make it work. If anyone is having this issue open your project with notepad and copy it. Then make a new project in Eclipse and past all your info.
Don't know why but its the only way it works.
Update SDK location if needed. Sometimes when you take a project
from one computer to another you need to update the SDK location.
Open project properties->'Java Build Path' and search for errors,
especially in the libraries tab. Make sure that all the resources
are present.
Clean project + Rebuild.

All my android projects have r.java related errors

For some reason my eclipse/android development environment has stopped creating the r.java files and wont read them in any of my projects. Should I just uninstall eclipse and all traces of it and the android sdk Ive been using and start fresh?
Ive been looking for the past couple hours for a fix but I cant find one at all that seems to work so any suggestions on the matter would help.
Every time I update my source I always do this:
Refresh project
Clean project
Refresh project
Works every time (unless I have a build path issue, then Right Clicking and Doing Android Tools->Fix project properties usually works)
Having build errors can keep the R file from being generated, make sure you don't have any syntax errors.
Try touching (making non-changing edit) one of your .java files and seeing if it forces the R files to rebuild. This appears to be a bug with Android SDK / Eclipse integration.
This happens to me a lot. Two things to try.
1) Try to clean the project
If that doesn't work. This usually works for me.
1) In eclipse delete the project (BE SURE NOT TO DELETE THE SOURCE)
2) Close eclipse
3) Open eclipse
4) Add the project back via New Project from existing source
You can try this:
Make sure that "Build automatically" option is on (under Projects menu)
Clean your project
Refresh your project
I fixed this by removing parentheses from a string title that I had created.
I am a complete n00b so I did not think that adding () to a title would cause problems.

Build path incomplete only in some workspaces (Android)

I have multiple Eclipse (3.52 "Galileo") ) workspaces so that I can keep related projects together in the same workspace. I switch between them with File > Switch Workspace.
I recently copied a good, working project to a different workspace, did a "File > Import" to import it in its new workspace, but after doing a Clean and Build, got the "The project was not built since its build path is incomplete. Cannot find the class file for java.lang.Object. Fix the build path then try building this project " error.
All my other projects build fine. I thought the "build path" referred to the search path Java or SDK files, so why would it only fail on one project ( ...a project that builds fine in a different workspace, at that)?
I've tried restarting eclipse, switching back and forth between workspaces, doing another clean and build, but no luck. Any ideas? Thanks in advance.
This may be a little late to help you, but in case others are looking, here's how I fixed it:
Right click on your project and select ‘Properties’. Then select ‘Java Build Path’, and the Library tab. Look for a JVM. If one is not there (broken link from your copied project), click ‘Add Library’ and add the default JVM. If a VM is there, select it and hit ‘Edit’ and reselect the default JVM. This should reestablish that link and fix the problem. Hope this helps.
I think Bill LaPrise might be right in most cases, but not in mine. What I eventually had to do was go into the folder where I have all my projects and delete the .metadata for Eclipse (be aware that you'll have to re-import all the projects afterwards! Also all the environment settings you've set would also have to be redone)
After it was deleted I just imported the project again, and it worked.
This was on Eclipse 4.2.0 Juno, if you're wondering.
For those encountering this error while using Maven:
Right click on the project, Build Path -> Configure Build Path...
Select the libraries tab. If Maven dependencies is not in the list,
you have identified the problem.
Close the dialog.
Right click on the project, Maven -> Disable Maven Nature
Right click on the project, Configure -> Convert to Maven Project.
Right click on the project, Maven->Update Project
Will Solve the Problem
Close Eclipse and run the below command from the terminal:
$ mvn clean eclipse:clean eclipse:eclipse
Right click on the project in the Eclipse 'Package Explorer'. Then from the drop down menu find 'Android Tools'. From the sub menu select 'Fix Project Properties'. It works wonders.
restart eclipse works on me. I am on Indigo.
In my case this issue happens after I install ADT manually by downloading .zip instead install from ADT site.
I solve the issue by right click on project -> Java Build Path. You'll see Android XXX, Android Dependencies, Android Private Libraries, Expand and click on Native library location (None), click edit button on right side then add path to ADT folder on eclipse on Location Path. Restart eclipse to complete

Eclipse - HelloWorld - Android error?

I created a Hello world app but get this strange error:
The project cannot be built until the build path errors are resolved
I haven't changed the project, jut created it and tried to run it.
to avoid that annoying problem i have 3 solutions that worked for me.
Solution 1)
delete your generated R.java file
inside your gen/ folder
Solution 2)
a)Delete your project from Eclipse
(i said ONLY from Eclipse, uncheck option: Delete project
contents on disk)
b) import your project to Eclipse:
file > Import > Existing Projects into
Workspace (Look for your project
previously deleted from Eclipse) >
Finish.
Solution 3)
make Solution 1 then Solution 2
It is either a spurious message you can solve by forcing Eclipse to recompute its library paths
I found the resolution for this at Scott D. Strader's blog.
To summarize the solution I only needed to add a library to my project and then remove it to force Eclipse to perform the necessary actions to resolve the problem. I would post the detailed steps here but I don't want to steal his content.
The resolution was to force a resave of the selected projects (and their .classpath files):
Open the project properties
Select Java Build Path > Libraries
Add a new, arbitrary library (to be deleted later) > OK
Wait for the workspace to refresh (or force a refresh of the project)
The error(s) will go away
Remove the dummy library
Note: as the OP mentions, a simple restart of the IDE can be enough.
Or you actually miss one critical library like a JRE library:
I needed to add the JRE library to the project for it to run. Not sure if this was due to the updated version or something else…. Any way this fixed the issue:
Project > Properties
Java Build Path
Libraries tab
Click add library
Select JRE System Library
Next
Finish
Sounds like you are missing an import or a jar. In your project in the project explorer there should be a red x on the file icon that contains the error.
In addition to the listed answers, there is one other scenario I've seen this error appear when using the sample projects included with the Android SDK. For some reason, the generated R.java file can be invalid or corrupt. You can get around it by expanding the "gen" folder in the Package Explorer and deleting the R.java file. It will immediately get regenerated and the error goes away.
Right click on your project, choose "Build Path", "Configure Build Path" -> and choose Android 2.2, or that target you specified when you created your project
I have had similar issues. for me simply closing the emulator and re-running the project works

Categories

Resources