So, I have searched the solutions for my current problem but it seems it can’t solve with my situation. I use eclipse Juno that I downloaded from developer.android.com.
First, I imported my existing files from C:\Users\Name\workspace. I also ticked to copy project into workspace. But then following error appears: (see this http://i.stack.imgur.com/inmRg.jpg)
Project has no target set. Edit the project properties to set one.
Project has no target set. Edit the project properties to set one.
Parser exception for /Astra/AndroidManifest.xml: Premature end of file.
Parser exception for /Astra/AndroidManifest.xml: Premature end of file.
And, everytime I copied my existing file to android workspace, all of the data imported in my C:\User\Name\workspace[Imported Project] is gone.. All the files became empty (see: i.stack.imgur.com/jFYhm.jpg)
After that, I also realized all files that I want to open can not be viewed in Eclipse Juno. (from file>open file>browse>open) It only shows [X] button but without the file name or the content inside. (see proof: http://i.stack.imgur.com/H6l6r.png).
add:
I also tried another method based on this reply:
stackoverflow.com/questions/2231474/how-to-import-existing-android-project-into-eclipse?rq=1
and followed these steps:
File → Import → General → Existing Projects into Workspace → Next
Select root directory: /path/to/project
Projects → Select All
Uncheck Copy projects into workspace and Add project to working sets
Finish
But in the end, it only shows this pop up:
An error has occurred. See error log for more details.
java.lang.NullPointerException
Please tell me what I should do. I can create new files and copy my data from notepad or else. But I prefer not to do that, because there is high chance that I need to import the project or refresh the project from my workspace. I want to know how to solve this issue.
Thank you for helping!
Create new Android project.
In Project Explorer in drop-down menu disable filter for .* files (Filters --> .* resource)
Now compare content of 3 files .project, .classpath, AndroidManifest.xml between new project and your project.
Related
I am using Eclipse to develop Android projects. I tried to reopen a closed project but got the following message...
The project description file
(.project) for is missing. This
file contains important information
about the project. The project will
not function properly until this file
is restored.
I thought I could just create the project from my source folders (by using Windows Explorer) but the projects are completely gone (and I hadn't backed up to an external drive)
Any suggestions how to get these projects back?
closing a project does not delete the .project file. something else happened to delete that.
To "recover" from this situation I would do the following:
Create a new android project.
Close eclipse
Copy the source from the former project into the new project (outside of eclipse).
Start eclipse.
Refresh the new android project.
Is your source for your projects completely gone? Did you check your workspace location?
If you still have your source you can create a new project and copy your source into it. (do this via explorer)
You can also try copying a .project file from another project. After the project opens you can then right click on the project and select 'fix project properties'
use window/show view/Package Explore (Alt+Shift+ Q P)
then in Package Explore window select your project
next step project/open project
its take me long time to find it.
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!
My apologies if this is a stupid newbie question...
I'm using Eclipse (Helios release) and have the Android SDK all configured as per the developer.android.com recommendations. I can create and run new projects without any problem but I can't import archived project code samples (found on the web etc.) using Import > Existing Projects Into Workspace.
Importing a zip creates a project but it doesn't create it as an Android project and the console displays the error: "Project has no default.properties file! Edit the project properties to set one."
I've tried going into the project Properties but as soon as I click on 'Android' in the properties tree a pop-up appears saying "Could Not Accept Changes: The currently displayed page contains invalid values"
See: http://screencast.com/t/ZmY3ZWQ4
But if I do this on one of my own projects I have no such error, and I'm able to change things such as the Android Platform/API level. I'm also able to archive my own projects (using export) and import them again without any problems... nut not other people's archives! Am I being really stupid?
Any help would be really appreciated!
All the baseline default.properties needs is a line like:
target=android-8
You can most likely copy another projects' default.properties into this project. A (not-so-)quick restart of Eclipse, a rebuilding of the workspace, and you're off to the races.
It's really lame that this is needed -- it should happen as part of the import process, I would think.
just change your
project.properties file to default.properties
and restart your eclipse
it's done..
Right click on the project in navigator window, go to android tools and click on fix project properties. It might work, as it did for me ;-)
You can look at this section, it works for me:
Project has no default.properties file!
If you want to change the library of your project, do that :
- right click on the project name
- Build Path
- Configure build path
- click Android on the left, and select the library you need.
I had the same problem.
What you are trying is little difficult.Just unzip the files ,copy res and src folders
to ur existing project.The problem is the files starting with "." which have settings for their android and eclipse.
So you need to modify all that,so simply create new project or to ur existing one copy res, src and AndroidManifest.xml file.
It worked for me .
In the project right click Android Tools -> Fix Project Properties
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
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.