I am getting the following errors when I try to load an Android project in Eclipse that was working just fine last week.
Any ideas?
[2012-03-16 09:29:43 - MyProject] /MyProjectName/gen already exists but is not a source folder. Convert to a source folder or rename it
Note that I have tried to clean the project several times, even restarted but it still gives me this errors.
right click on project and go to project properties, then goto java build path, and then in source tab, click on add folder button and add gen folder.
just src and gen folders should be checked there if you haven't any library projects attached.
MyProject] /MyProjectName/gen already exists but is not a source folder. Convert to a source folder or rename it
This problem happens when eclipse does not able to find each linked contents in a project.
For example:
When we import a project to eclipse from a specific folder(suppose D://NewFolder), eclipse memorized and link each content with its appropriate path (which is D://NewFolder/project_library/src in our example).
But if we replaced(Here D://NewFolder To E://Another_Folder) or delete the library from its specific folder(Here D://NewFolder), eclipse unable to find its(project_library) original path
and give red error.
So when this problem happens, first we have to make sure that the imported project or library is its original folder and no changes has made to this.
Otherwise again replace the project to its specific folder to which eclipse has linked at the time of import i.e parent folder.
This happens because your .classpath file got wiped out somehow. This file contains all the information from the Java Build Path tab under Project Properties. You could add in all information manually but there's an easier way of fixing this problem.
If you have a copy of the .classpath file on your machine, you can just copy and paste it into your project directory.
Follow these steps in Eclipse :
Project -> Properties -> Select Java Build Path ->
Open Source tab -> Click Add Folder and check the gen
Related
I have a project in Eclipse that somehow does not group the 'res' or 'bin' items in the package explorer into groups but shows them as individual items with 'white' folder icons.
The image shows this. In the 'Countdown' project you have res.layout, res.menu etc. but in the NewProject these are both in the 'res' folder.
The CountDown project also refuses to build with the error 'R cannot be resolved to variable'. I know this is due to the fact that the R.java file is not created by the pre-compiler and I assume this is also related to the fact that the folder structure looks different.
Now I have already tried many things like cleaning the project and rebuild manually but so far nothing solves this problem.
Check your project settings: right click the project -> Properties -> Java Build Path -> Tab Source. Compare these settings with the other project.
I think you have directly import a project into eclipse and you are on Linux System. As Linux has its own security, i suggest you to find .class & .project files in your project folder ( which are hidden, so use CTRL + H to view ). Now right click on these files and change its permission. Come back to Eclipse, refresh the project and clean. That's it.
I'm studying this tutorial now:
http://www.ibm.com/developerworks/opensource/tutorials/os-eclipse-android/
I got an error says "project contains error" when running the code. But I didn't find any error mark in my project. What happened? Thank you very much!
Right Click in your project - Properties - Java Build Path - and then you will see the error, so you just have to delete the error and then clean your project
There is an R.java file in your src directory, and while it used to go there in previous versions (as I just learned), it doesn't belong there any more.
That file is generated by the platform, not you, and should appear in the gen directory.
The copy in your src directory is probably interfering with the real R.java file in your gen directory. Remove the file from src and Eclipse will be happier.
I want to be able to use a single set of source files between an sbt android-plugin project, that I'll build from the command line. I'd like to be able share the same AndroidManifest.xml file as well as the res directory.
Is there a way I can get Eclipse to create/import the Android project from the sbt project's src/main directory?
Here's the kludge I used to get it to work.
First, create a temporary Eclipse Android project in your workspace with the relevant source code, manifest, resources, etc. I'll refer to this project as EclipseProj.
Next, create an sbt android-plugin project from a shell in the same directory as your Eclipse Workspace. I'll refer to this project as SbtProj.
Then, move the src folder contents of EclipseProj to SbtProj/src/main/java, as well as the AndroidManifest.xml file and the res folder. Optionally, make sure you can build SbtProj.
Next, move the .classpath, .project, and project.properties files to SbtProj/src/main.
Now you are ready to import the sbt project into Eclipse. Delete EclipseProj from within Eclipse (don't delete the files on disk yet, in case you missed something.)
From Eclipse choose the import menu, "Existing Projects into Workspace", and click browse to select root directory. Choose the path to SbtProj/src/main, then click the checkbox to import the project. I'll refer to this new project again as EclipseProj since we removed the old temporary version from Eclipse.
Now your project is imported, but the source is missing. Right click EclipseProj in Eclipse and select project properties. Click the Java Build Path, then the source tab, and the "add folder" button. Select the java checkbox.
Now do a clean build in Eclipse and verify that EclipseProj builds. If it does, and the SbtProj does as well, you're done and you can delete the original EclipseProj temporary project's files.
I have an Android project developed on Eclipse (GNU/Linux) that I last touched half a year ago. I am trying to import the project into Eclipse 3.6 on Windows (with ADT installed) installed using File -> Import Project in Eclipse. When the project is imported, I see the following error twice on the console:
[2010-12-10 02:17:12 -
com.android.ide.eclipse.adt.internal.project.AndroidManifestHelper]
Unable to read C:\Program
Files\Android\android-sdk-windows\AndroidManifest.xml:
java.io.FileNotFoundException:
C:\Program
Files\Android\android-sdk-windows\AndroidManifest.xml
(The system cannot find the file
specified)
Why is Eclipse looking for AndroidManifest.xml on the Android SDK path? The file actually seems to be in the project's directory. How do I fix this problem and get the project to compile?
A simple solution is to either reimport the AndroidManifest.xml file or make a change to the file and save it. This worked for me.
If you see an error about AndroidManifest.xml, or some problems
related to an Android zip file, right click on the project and select
Android Tools > Fix Project Properties. (The project is looking in the
wrong location for the library file, this will fix it for you.)
from: http://developer.android.com/resources/tutorials/notepad/notepad-ex1.html
The way you are importing the Android project into Eclipse is wrong. The Correct way of doing is File -> New Android Project. In the Contents Tab in "New Android Project", select "Create project from existing source" and choose the Build Target. That should fix your problem.
It appears that this error is produced because Eclipse thinks the default location for new Android projects is the Android SDK path. Even if the project location is changed, the error fails to be resolved, so the trick is to change the project location before Eclipse is aware of the condition generating the error.
To circumvent this quirk I imported the old project with the following steps:
File -> New -> Android Project
Un-check 'Use default location' and browse to project root directory.
Click 'Create project from existing source'
It's important to do step (2) before (3) otherwise the error persists and prevents running the project.
I had the same problem, all of the above did not work. I cleaned the project and it worked.
Instead of using File ---> New Android Project --> "Create project from existing sources", which will result in the error your are seeing, choose "Create project from existing sample" and choose it from the drop down. This will work.
Experienced JAVA developers tend to go with the first option which is normally there and works for classic Eclipse projects. But this is not your typical project and I bet the Google developers put this special case in the wizard to accommodate the differences.
I had the same problem. I was trying to compile the JakeWharton view page sample, so I checked out the GIT in a directory in a different folder then the workspace which caused the problem.
Eclipse was maintaining 2 folders:
1. A new workspace folder was made under the workspace directory, which eclipse checks for libraries and others source code including the AndroidManifest.xml file
2. The existing folder which was not under the Root workspace
To fix the problem after importing I had to manually move the files in the new workspace folder created by eclipse.
I met this problem when using Facebook SDK, now I solve it by doing this:
Close the project;
Copy "AndroidManifest.xml" file to the project's root path;
Open the project and refresh it, it's Done!
this worked for me by the way:
I changed the project name to the exact name of the project that I am importing.
Eclipse seems somewhat fragile in its naming conventions. One of the causes for this error is a difference between the project name and the folder name in the workspace. I imported a zip file for a project named "HelloDialogs" into a workspace folder named "HelloDialog". This caused the "AndroidManifest.xml file missing" error. Once I renamed the folder correctly, everything worked fine.
Because of the multiple different answers here, I thouhgt I'd add yet another one that worked for me, as I had exactly the same issue when first working with Phonegap android dev tools.
So I found (as mentioned by Gintautas in comments to the accepted answer), that I had to create a new project using the phonegap 'create' script, then when importing the project into eclipse. the only way to get this to work successfully was if the project was originally created in some temp folder somewhere other than the place I actually want to work with it.
So I created a project in windows like this in a cmd window...
c:\phonegap\phonegap-2.6.0\lib\android\bin>create.bat c:\temp\android_boilerplates\test app.test test
Then I imported the project in eclipse like this...
File > New > Project
Within the new project wizard select: "Android Project from Existing Code"
Click "Next"
Now navigate to the temp location of your project and set that to the root directory, check the project you want and check "Copy projects into workspace" as the example below...
Click "Finish"
And that's it, Eclipse should copy all your project files into your workspace and there shouldn't be any errors in your project (fingers crossed).
Your project should look something like this...
Hope that helps, it took me an age to work out why Eclipse didn't like creating a new project from existing code when the new project was being setup in the same place as the existing code. This isn't a problem for other languages I've used, so it was a little weird, but understandable as Eclipse (I'm guessing) seems to want to overwrite certain files.
Eclipse randomly decided to make another folder instead of the one that i had specified, but doesnt have any resources or data or layout etc in it..
it has some conflicts i guess..
anyway, a noob approach to this was, copying the original file to some other location(i put it to desktop)..
now create new project-create existing project, select this one from desktop, n VOILA.. its all fine.. :D
I am a little late to this game but I caused this same problem by generating the initial application into the exact location I was going to work on it. That is to say I put it directly into my current workspace. I then did File, Import, Existing Android Code Into Workspace. The import process blanked out my android.xml file.
I tried above solutions and had no joy. I then generated the initial application into a temp directory and imported from there. This worked for me.
The only way to import a project into eclipse workspace is to create an empty project and then drag and drop all the folders and files into this project. Why is this so is beyond me.
The answer from Raunak is wrong.
I found a .classpath file in the root directory of my Android project. I opened it and updated the file paths in it, and it seemed to fix the problem for me.
I had the problem when I tried to update an old project with recent code from the SVN. I had the Manifest.xml exported to my local file system as backup and deleted it. I've then reverted my complete project to the most recent version from the SVN and then it worked :)
This is what I had to do to get this to work. Fortunately I had backups of earlier "project".
1) Import the project as usual.
2) If the errors with empty xml etc. comes up, close the project.
3) Go to the original project if you have backup.
4) Copy all of the projects root files and directories and paste it over where Eclipse expects the projects root directories and files to be.
5) Open the project and refresh. Make "Clean" if necessary and you're done!
Always make backups because Eclipse f--kups! I learned this the hard way when suddenly my Android project refused to work because of empty manifest-file.
Sometimes if you automatically fix imports in MainActivity IDE imports android.R class instead of one that will be generated for the project. Remove the import and recompile.
when importing project from another workspace add existing project in workspace. and tick to the copy projects in workspace.then check the api level and supporting library from project.properties files.then rebuilt project and clean it.. it is works for me.
2017 Solution: Much Easier and tested solution is to remove your application folder from elipse project only then Import it again and the problem will be fixed immediately!
I'm pretty new to android, and just finished setup my environment and reading some tutorials. Then I got sdk samples from the web. Okay, what I wanna ask you is that is there a way to start a sample as a project in the Eclipse? I mean like clicking a project file in c# or a solution file.
Here is my folder which I unzipped the code,
\android-sdk-windows\samples\android-8\NotePad
There are three folders and one file in the folder, \res, \src, \tests, and AndroidManifest.xml
Or, do I need to make a new android project and import (or add files? maybe) them?
Thanks in advance,
yokyo
#sgarman
I don't think that's a very good way of doing it. Sadly the 'Create Project from existing sample' feature you describe functions in such a way that when it creates a project from a sample it leaves you editing the source code in the actual SDK sample itself instead of a copy of the source imported into your Eclipse workspace.
This is problematic for a number of reasons including:
Once you've edited the new project you no longer have the original sample to refer to, which is the whole point of the samples in the first place.
If you want to hack a sample in several different ways you will want several copies of the sample, but again once you've edited the original sample you no longer have the original sample to make a copy from.
If the SDK is ever patched then when you update it you may end up overwriting your code.
In short it makes far more sense to treat the SDK as a readonly reference and not treat it as a sandpit in which to do your own messing around. So imo the best way to create an Eclipse project from a sample is do take a copy of the sample and put it somewhere else.
If you want the sample to not exist in your actual Eclipse workspace directory then this is very easy. Just copy the sample to a new location and inside Eclipse with your workspace open do New->Android Project and 'Create Project From Existing Source'.
If on the other hand you want to make the project inside your Eclipse workspace directory then there is a problem which is that if you just copy the sample code inside your workspace folder and do 'New->Android Project' and 'Create Project From Existing Source' for me at least it fails with the error "Invalid project description: c:\Users\usernamme\blah\blah\projectname overlaps the location of another project projectname". I don't know why, if you create a project from sample code using 'New->Java Project' it works just fine so I suspect there is a problem with the Android Project Eclipse plugin that is causing this to fail.
There is a way to get around this which is to first copy the sample code to a temporary location on disk that is outside of the workspace directory. Then use New->Android Project and 'Create Project From Existing Source' which turns the temporary copy of the sample code into a project but leaves it orphaned outside the workspace directory. Then delete the project from the workspace (but without deleting the project from disk). Then use Import->Existing Projects Into Workspace with the 'Copy Projects Into Workspace' checkbox ticked to copy the project into the workspace directory, before finally deleting the project from the temporary location.
But ultimately I decided to structure my workspace in such a way that projects are not inside the workspace folder like this:
Eclipse Workspaces
\
Android Projects
\
Workspace
Project 1
Project 2
Java Projects
\
Workspace
Project 1
Project 2
Other Projects
\
Workspace
Project 1
Project 2
In this layout the Android Projects, Java Projects and Other Projects directories are conceptually my workspaces but in reality in each case it is the nested Workspace folder which is the actual Eclipse workspace. This enables me to keep my projects contained within their respective pseudo-workspaces while not being inside their actual Eclipse workspace folder which neatly gets around the problem of not being able to easily create Android projects if the project directory is inside the Eclipse workspace directory.
Sorry that's all a bit long winded, but it's taken me ages to work out how to get this to work efficiently and I figure it might help someone.
From eclipse go to: File > New >
Project...
Select the Android Folder and pick
Android Project
Then in the Contents section at the
top click the "Create project from
existing sample" radio button. Once
you pick a target from the bottom
the drop down will become selectable
and your good to go.
Copy the downloaded project into your workspace
i.e space allocated for android project
Open the Eclipse
Choose File---> Import ---> Android --> Existing Android code into workspace
Choose Next
Click Browse
choose the foldername (downloaded)
click finish
If you are using ADT 20 then it's quite easy. Select New > Other...>Android Sample Project > [Select the platform from which you would like to pick the sample] > You must see the available samples, select the one you wish to open,you will see that in your workspace.
This may not be a definitive answer because I'm relatively new to Android as well (and come from more of a .Net background too).
When you create a new Workspace in Eclipse, you'll see a new folder created with the name of your workspace and a .metadata folder inside of it. I don't think there's a "workspace file" per se, so you don't double click anything to bring it back up. You just open to that workspace (by telling the Eclipse dialog what path to open).
As far as importing existing projects into a workspace, copy the whole folder into your workspace and click File - Import... - General - Existing Projects into Workspace. Click the Browse button to select the Root directory and it should default to the Workspace's main folder. Click OK and the project should show up in the dialog. Select it and click Finish
The code samples don't come with eclipse project files out of the box. There are a number of ways to create them but the easiest is probably this. From eclipse (with the android plugin installed), File -> New -> Project, Android Project, Next, select the "Create project from existing source" radio button and specify the location of the existing source. The project wizard should then find your manifest and fill out the rest of the information it needs automatically.
http://developer.android.com/samples/index.html
It states here:
"Using Android Studio
Unpack the downloaded project package.
In Android Studio, chose File > Import Project and select the root folder of the unpacked project.
Android Studio may ask you to choose the type of project you are importing. If this is the case, make sure to choose Import project from external model and select the Gradle option."
I hope this helps you.