Error when importing an existing project to eclipse - java

So I'm trying to import an existing project to eclipse and when I do I get the following error. The main folder of the project in the package explorer has a red exclamation mark (!) next to it and console says the same error 3 times:
[2013-07-10 14:23:39 - Myproject1] Project has no target set. Edit the project properties to set one.
[2013-07-10 14:23:39 - Myproject1] Project has no target set. Edit the project properties to set one.
[2013-07-10 14:23:39 - Myproject1] Project has no target set. Edit the project properties to set one.
I did my research on this error and found a bunch of stuff on this website already but nothing helps. People are mostly getting this error when they try to execute the imported project, not as soon as they import it. I also tried setting the "target set" in the project properties, as the error tells me to, but I can't find where to set the "target set" anywhere in the properties.
One more thing worth mentioning also, if I open the src folder and try to open any of the *.java, everything is blank, the "code" opens but it's blank. Any help would be greatly appreciated!

The file 'project.properties' is missing. It must reside in the root-folder of your project.
( Where the AndroidManifest.xml is located )
You should create a new android-project and import the sources and resources
OR create it manually.
Example content for project.properties:
# Project target.
target=android-17
Greetings
Christopher

set android target version on your project manifest xml file or eclipse ->right click project click properties->select android tab->check latest android version on the list like below screen shot:
after click ok button will apply wait some seconds after your issue will be solved!

you should try fixing project properties:
rightClick on Project -> Android Tools -> Fix Project Properties.
That resolved my issue!

You are probably importing your project folder on your workspace. In my case, i got that same error, so i just move the project folder to "C:" and tryed to import again. And bingo!

Related

"Cannot resolve symbol" in Intellij IDEA

I'm fairly new to Intellij and Java and am unable to use libraries from one "module" in another. I am seeing red class names and getting "Cannot resolve symbol ..." errors all over the place:
The other modules are referenced in File | Project Structure all the other module's Paths are correct and include the *.classes I'm trying to use:
I have also tried a File | Invalidate Caches but am still having the same problems.
What do I need to do to fix this?
Listed below are steps which may fix the problem:
1.Invalidate and refresh the IntelliJ's caches
File Menu -> Invalidate Caches / Restart -> Invalidate and restart
2.Project SDK selection
Check project settings from File Menu -> Project Structure
Ensure an SDK is selected for the Project SDK. If is selected, click the 'New' button, select JDK and then select the correct path to the JDK e.g. /opt/java/jdk1.8 or c:\Java\Jdk1.8
3.Corrupt JDK
There may be a problem with your JDK installation, re-install JDK
4.Re-import the project
Close the project if it is open in IntelliJ
Delete the .idea folder in the project source code folder.
Start IntelliJ and Import the project.
You can choose any of them which will work for you.
I faced a similar problem for no reason, I think it was caused by IDE(android studio). I have tried all of the above solutions but not worked. Finally, in my own situation, I solved this problem by the following actions:
Delete your .idea folder in your local project.
Reopen this project and just let Gradle run itself.
It was worked for me. I hope that my experience will be useful for you.
You need to add your external libraries/classes under dependencies in order for IDEA to see them when doing code analysis/autocomplete.
You can go to "File->Project Structure"
From "Project Settings", Select "Project" tab and there make sure that "Project SDK" has proper JDK selection.
After you add dependencies to POM file, make it a habit to refresh POM by clicking on the 'Reimports maven projects' icon. Its the first icon in the maven tool window located to the right of the main intellij editor. Its a blue icon with 2 circular arrows. Clicking it ensures that the added dependencies are fully integrated into your project
Run it from the project's root folder.
$ mvn -U idea:idea
One more advise would be to make sure that you import the project properly. If it's a maven project, import pom.xml and if it's a gradle project, import gradle.build file to make sure that all the dependencies are downloaded correctly.
Just got this.
Just went there.
Invalidated the cache.
Seemed to work until I wrote further lines.
Then noticed that I was writing my code outside of the main() function.
Moved the ending curly bracket further and voila.

Importing Android project into eclipse gives me two project

I am importing the following project : ActionBarCompat-Basic from the Android Developers website into Eclipse.
by doing so: File -> Import => Android existing project.
However, in my package explorer, it creates me two projects :
1) The first project is named MainActivity
2) The second project is named tests.
Also, the two projects both have errors
Is that normal ? If yes, how can I solve the errors issue ?
Note, because you do not say wich project you are importing, this a blind answer.
You get two project simply because in the downloaded folder are two project.
To resolve errors first of all try to do a clean Project=>Clean... and select the projects you want to clean.
Unfortunately errors are common when you import project coming from around the web.
You should right click those projects, open Properties and check the Android tab, check if you are missing some library and try to figure out wich library is (or are).
Check Android 4.4.2 as build target.
Open the Java Build Path tab and open the Source tab, check if the gen and src folders are there, if not, add them.
If error are still there open the files marked with the error icon and try to figure out wich library they miss.
Check the Eclipse error Log.
I hope this help.

Eclipse - Android Project from existing Code does not work

i'm trying to import a folder with an existing project in Eclipse, but it wont't work.
CTRL + N --> Android Project from existing code --> give folder directory --> Finish
Once i try that, nothing happens. Nothing loads, Eclipse doesn't give me an error output, just nothing. Odd thing is that it just happens like that on one single project. When i try to import other projects, everything works just fine.
I am a 100% certain that my project is not corrupted or anything. I just removed it from the Package Explorer and now it won't work anymore.
Thank for your help :)
Once try this:
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
If you just removed the Project from Project Explorer, then Eclipse specific files (.project and .classpath) must be still there. Try to import it as existing Eclipse project: Import -> Existing Projects into Workspace.
I had this problem recently. As it turns out, the AndroidManifest.xml contained a duplicated entry (syntax error), causing a parse failure when Eclipse tried to decode it.
After I found the duplicate line, removed it, and re-added the project to my workspace, it showed up in Package Explorer just fine.
Hope it helps.
For my case there was a problem in manifest . Check whether Manifest is proper or not or any other Xml file has any sort of problem .

Error in Eclipse: "The project cannot be built until build path errors are resolved"

I am a computer science student learning Java, so I do some work at home and at college on a mixture of Linux and Windows. I have a problem after copying a new project into the Eclipse workspace. The project shows up, but with a red exclamation mark and an error saying:
The project cannot be built until build path errors are resolved
How can I fix this? I tried the solution described here, but it didn't work.
Identify "project navigator" or "package explorer" view.
Right click on your project, select Build Path --> Configure build Path.
In the emerging window, you will find four tabs, select "Libraries".There, under "Web app libraries" (expand it), you will see the libraries added to the project's classpath. Check if all of them are available. If one or more are not (they'll have "missing" beside their name and a red mark on their icon), check if you need them (perhaps you don't); if you don't need them, remove it, if you need them, exit this window, look out for the missing jar and IMPORT it into your project.
Open the Problems view. You can open this view by clicking on the small + sign at the left hand bottom corner of eclipse. It's a very tiny plus with a rectangle around it. Click on it and select problems.
The problem view will show you the problems that need to be resolved.
If the message says "the project is missing the required libraries...", you need to configure your build path by right clicking on your project, selecting properties, then build path. Add the required jar files using the libraries tab.
-If there are other problems other than missing libraries, you need to post the exact problems here to get a precise solution.
If you can't find the build path error, sometimes menu Project → Clean... works like a charm.
In my case, all libraries in the build path were OK.
To solve it, I deleted all project metadata (.project, .classpath, .settings) and re-imported the project as a Maven project.
Right click your Project > Properties > Java Build Path > Libraries
Remove the file with red "X" (something like JRE...)
Add Library
That's how I solved my problem.
I also had this problem in my system, but after looking inside the project I saw the XML structure of the .classpath file in the project path was incorrect. After amending that file the problem was solved.
If not working in any case...then delete your project from the Eclipse workspace and again import as a Maven project if that is a Maven project. Else import as an existing project.
I tried all the previous given solutions, but they didn't work, but it works for me.
In Eclipse, go to Build Path, click "Add Library", select JRE System Library, click "Next", select option "Workspace default JRE(i)", and click "Finish".
This worked for me.
Go to Project > Properties > Java Compiler > Building
Look under Build Path Problems
Un-check "Abort build when build path error occurs"
It won't solve all your errors but at least it will let you run your program :)

Can't find R. layout - app name. Only android layout

For some reason, when i started up eclipse today, it couldn't find my main XML in my
setContentView(R.layout.main);
When i write R. it can only find "Layout - Android.R" - and not my "Layout - com.your.app"
Anyone who knows how to solve this problem?
I just realised my Java file in the /gen folder is missing, how do i retrieve it again?
Cleaning project doesn't work
You need to remove the import android.R statement at the top of the file.
See here for more information:
http://source.android.com/source/using-eclipse.html
Try Right click on project > android tools > Fix Project properties
Project > Clean
Project > Build Project
Option 1)Project > Android Tools > Fix Project Properties.
Clean and Rebuild your project.
Option 2) Refresh your project F5, Delete folders /gen and /bin then Rebuild your project
Option 3) update the build tools, some time this will cause a lot of problems and you will have the annoying message related to "Can't find R.layout"
But in this case you wil fix, delete because you don´t need this:
import android.R;
i think this is your problem.
Folder /gen is automatically generated, but you will solve problems related to resources, probably something missing in your layouts, one of them will have a warning or error.
check you are importing the current R class, and enable Auto Build under project menu, if enabled, then use clean under the same menu to rebuild the R class
It can be that your project contains errors. To see list of resources it must be able to compile. After that your resources will apear.
I got the same problem with one of my project where I copied an existing XML file (say xmlfile) over.
Then, Java file cannot resolve R.layout.xmlfile.
I guess it is probably due to the end of line feed/CR compatibility between Windows and Linux.
so, I pruned all the LF/CR and re-saved it on my Mac machine.
Then, the problem is resolved.
Hi had same problem few minute ago. I kept looking and looking and finally i found out -- >
Its because i was using a file in drawable folder with
1-launch-screen.jpg (Invalid Name for drawable file)
Make sure your file name has valid.
It can not have any '-' character in drawable filename.
File name has to be all small letters only.
And that red X mark automatically disappeared and project started top built and i was able to see R.layout.MyNewLayout.
Hope this helps !

Categories

Resources