Related
Ok, so I decided to import my github project into my other machine on AS. The problem however is that AS seems to completely forget it's an Android project and treats the project as a simple directory. I can't build, rebuild or even run my project. Additionally my file structure is gone.
I've tried importing based on external models but my Android Manifest can't seem to recognize my strings resource folder either. So importing is out of the question.
Any help is appreciated thanks.
It's because you're missing a lot of the files that AndroidStudio creates with you start a new project.
A simple way to fix this will be to create a new project with the same name, package name, all that, and then just copy over your app folder.
When you reopen the project it will recognise it.
this happened to me due to that the file called build.gradle and other similar files wasn't in the root directory like when I opened my imported project I see these files :
but it should be like this :
so I navigated to the directory that contains the files in the above photos and imported that file as an android project and I succeeded, but there may other reasons for your problem , so you should clarify.
You do not have a build.gradle in the root folder of the project, maybe that is the reason.
Without the build.gradle file android studio cannot perform a correct import of the project.
Before coming to the problem let me explain what I did that has landed me in the problem.
I created an account on github and made a repository named Android.
Then I installed github client in my windows 7.
Then I opened this client, provided my authentication and cloned the repository to a local directory C:\Users\Aniket\Documents\GitHub\Android(This folder has the .git folder in it).
Then I went to my Eclipse ADT and installed EGit plugin as described here. Also I
Then in Eclipse I right click on my project TicTacToe go to Team->Share Project and provide my repository path i.e C:\Users\Aniket\Documents\GitHub\Android.
My Project was added to the local repository and in my github client it shows me all option to commit file in the actual repository on the github site.
But my project is suddenly showing error with a red '!' sign on it.
Description --> Archive for required library: 'C:/Users/Aniket/AndroidWorkspace/TicTacToe
/libs/android-support-v4.jar' in project 'TicTacToe' cannot be read or is not a valid ZIP file
Resource --> TicTacToe
Path Location --> Build path
Type --> Build Path Problem
Note : the Error was a single line displayed in error console on Eclipse. I just split it up for readability.
Even after detaching repository it shows that error.
Has anyone encountered this scenario before. What is the solution or workaround? I googled and first few links suggest it is an Eclipse bug. Please suggest what can be done to bring my project back to executable state?
It is an Eclipse bug. I have faced the similar problem several times. closing and reopening the project works sometime. if it doesn't work try restarting Eclipse.
I've seen the same issue. I removed that jar file, and then rightclick on the project, select maven, and do "update project...". The jar was downloaded again, and the problem was gone.
There is other case to display error Archive for required library
Right click on project and open --> project project properties --> java build path --> Android private libs
if there are two jar files with same name then remove one from libs.
jar file may the hidden some times then
open you libs folder in window and check if any hidden files are exist
Organize --> folders and search options --> view --> check show hidden files
and Delete the hidden jar file , The same cass delete if hidden java fies exist in src and packages if any
Looks like everyone has different story to tell! For me, I had to delete the error from eclipse Markers tab, and then cleaned the project again. Before that, I closed and re-opened the project/eclipse several times as suggested by #rachit, which did not work for me.
In my case, i'd downloaded project from internet, after unzipping project some files had been blocked, just unblock files and try again, then problem was solved.
In my case I tried all the tips suggested but the error remained. I solved changing version with a more recent one and writing that in the pom.xml. After this everything is now ok.
In my case restarting Eclipse did not solve the problem. I restarted the computer and did a Project -> Clean in eclipse
A solution that worked for me:
go to *.classpath and delete the line :
<classpathentry kind="lib" path="the_problematic_class.java"/>
Could be due to corrupted jar files as well. Better to check that first as that was the reason in my case:
jar tf myjar.jar
should list the content inside.
i was facing same problem in Eclipse Mars. I downloaded the jars from [https://oss.jfrog.org/webapp/#/artifacts/browse/tree/General/repo/org/ethereum/ethereumj-core/1.0.0-SNAPSHOT][1]
and replaced it in the directory.
I got error while adding ethereum.jar using pom.xml at C:\Users{machineName}.m2\repository\org\ethereum\ethereumj-core\1.0.0-SNAPSHOT\ethereum-core-1.0.0-SNAPSHOT.jar , i added the downloaded jar(ethereum-core-1.0.0-SNAPSHOT.jar) here and the problem was solved.
I will say that it can be that some answers work for some cases, but for me it was necessary to go an extra mile. So I will try to make a summary of what can be done:
Verify that the jars are intact:
jar tf myjar.jar
Restart eclipse and update projects setting over right click on project -> Maven -> Update project
The option which has work for me was to navigate in the workspace folder and then delete the files:
.metadata/.plugins/org.eclipse.jdt.core/invalidArchivesCache
.metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache
After that restart eclipse and rebuild project.
I found no duplicates anywhere and tried restarting eclipse, rebuild project. I was getting error for only one libary. So I just tried to rename the jar file from ksoap2-android-assembly-2.5.8-jar-with-dependencies.jar to ksoap2-2.5.8.jar
So if none of the problems solves from above you can also try this one
In my case, the java installation was not proper. So, I uninstalled Java and reinstalled a new version. Now, it works.
For us, the problem seemed to be the size of the .jar file. I would recommend doing the following test to see whether this is the case or at least rule it out. First have a look at other jars in your Eclipse project and compare them to the problemetic jar. Is it a lot bigger than the others? If so, try the following workaround. Else, this answer probably won't help you. Before starting, configure Windows to treat .jar files as .zip files with the following command line command:
assoc .jar=CompressedFolder (see https://superuser.com/questions/121540/can-you-configure-windows-to-open-jar-files-like-zip-files-without-a-3rd-party-t)
Optional: A simple Test
Before trying the workaround, here is a test to see if it is indeed the jar file size that's tripping you up.
Create a large .jar full of random .class files that aren't in your problematic jar. You can do this by making a folder full of files, zipping it, and renaming the .zip extension to a .jar. Windows might warn you about changing the extension. Ignore this. Make sure you have enough files in the folder so that it's a bit larger than the problematic jar.
Try to import this artificially created jar. If it fails with the same error, then size is probably the issue.
The Workaround
If it is indeed size that's the problem, which you might have identified by doing the optional simple test above, you can try the following workaround.
Decompress your .jar file. You should be able to do this easily in Windows
Split the folder you get from step 1 into smaller sub-folders. It could be just two folders, or more, depending on how big the original is. You want the folders to be smaller than some of your existing "good" jars so that size won't be an issue. Make sure to keep the package structure intact when you're doing this.
Zip up all the folders you created in step 2, and rename the .zip to .jar.
Import all of the .jars from step 3 individually.
The steps might be a bit unclear, so here's an example. Imagine your jar file was called mylib.jar. You unzip this to a folder called mylib. Inside, let's say there are three sub-folders called package1, package2 and package3. Create 3 folders called mylib1, mylib2 and mylib3, and put in package1, package2 and package3 respectively. Then zip these up and rename extension to .jar. You'll then be importing mylib1.jar, mylib2.jar and mylib3.jar.
For Java web application, web.xml added as jar in the project. In project explorer, try to find web.xml as in jar icon and remove from the project. Error will go away!!
I was stacked on this problem for days despite searching for a solution on the net. I first moved my project to Netbeans and all worked fine. I then returned to eclipse->properties->java compile-> Building and changed "Incompartible build path" option from error to warning and then did maven update and it worked.
I realize this is an old question, but I have yet another solution if none of these work for other people coming across this thread.
I had this same problem, and spent alot of time trying to figure it out, only to find that my Eclipse classpath/buildpath has a .json file in it, it doesn't like that, so it wouldn't compile.
So, check to make sure no text files or json files, etc are in your build path.
I had accidentally put the web.xml into the build path :x
I just did an update of Android Studio and the project I was working currently on was completely erased. I think it prompt me on "terminating the main process" and I accidentally clicked ok. Is there a way to recover my project somehow? Why would the files be erased by simply updating?
In my case i didnt lose the whole project just the main folder which contains the java and the ressource file
I right click the project --> local history --> show history
--> revert selection
If you dont have the project you can create one with the same name same file names then do exactly the same thing as mentioned
Its a lesson to use github :v
I've had the same situation. I haven't been able to replicate the behaviour. My hope is the details bellow will contribute to some answer.
I was working on a project that required the addition of some JAR dependancies. The JAR dependancies, were added to the lib file and I was editing the project build.gradle script to compile them.
I was adding a dependency for jackson JSON to the build.gradle file when the issue occurred.
While typing 'compile com' android studio locked up for a moment. All the files in the project manger disappeared. Android Studio ran thru a gradle build.
Initially I though I'd inadvertently opened an new empty project. Unfortunately my files were gone.
Android Studio Never Closed or Crashed
The Folder which contained all the project files was completely empty. As if a batch deletion had occurred.
'File -> Open Recent' showed no evidence that the given project had been opened.
I had been working on this file during the previous 24 hours, opening it thru the 'File -> Open Recent' that morning to pick up where I left off the previous day.
It was Disconcerting.
I got the answer from the same problem here.
The project is not erased,just moved to another place, I also don't know why.
I just search my project's name in all my disk, then find the project under another folder.
I use the Mac OS, so the new folder is-
/Users/jokerlee/Applications/AndroidStudioProjects
I am having the Same problem even now on Android Studio 3.1.4.
The entire project folder is wiped out.
But what I do currently is immediately save the entire project folder somewhere, like Company Folder, then Copy and paste again. Hectic though.
Done this ten times now. I will test not using default project location like /users/........
I face same problem too. I solved the problem by doing following steps.
In Android Studio, open the project main directory.
File -> Open -> Folder path where your missing project existed.
Lets say if your missing project is under ../AndroidStudioPrj/MyApp, please open AndroidStudioPrj directory.
Then VCS -> Local History -> Show History
In history, you can revert to get back your code.
[
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!
After I added some .png files into my Project Workspace drawable folder I refreshed my drawable folders in Eclipse and the newly added files showed up. But when I tried to access those resources using R.drawable.xyzimage, xyzimage although in the folder could not be resolved.
So I did a Project Clean and guess what after this clean R.java is totally gone and all my classes accessing resources using R.java is showing all sorts of error and Eclipse won't let me run the code anymore.
I have backup of my source code but I want to explore if R.java can be regenerated and how?
Thanks for all the help.
Try Project->Clean in Eclipse. In my limited experience if R.java is not being automatically created then there is an error somewhere in your xml. Triple check everything.
You have to build the project to be able to use the newly added resources.
Cleaning a project removes all auto-generated files. Building the project it should automatically create them. When you Clean a project, there's an option to start a build immediately after clean up.
Here's a few things you can try (did the same procedure after manually deleting the "gen" directory.
After you have deleted the gen directory, go to Project > Clean ...
You should have errors indicating that R cannot be resolved to a variable. Right click on your project from the Package Explorer and select Build Project. Be sure Build Automatically option is turned off (uncheck in Project > Build Automatically).
Errors regarding R should have now disappeared. Now, perform a Project Clean once again. All errors should be gone.
Let me know if this works for you.
Here is what the problem was. I added those new png images to the project and android has rules as to what characters are allowed in the names of these images. Once I changed the uppercase letters in the image name, it was back on track again and Build Automatically generated the R.java file and all errors were gone. Eclipse console is the place where I found all the errors related to my resources.
Thanks Guys....I tried your solutions but my error was something specific which was due to my image naming convention so this is the way I fixed it.
I would agree this is usually a XML problem but moreover that it is something within your res folder that is the problem and may be highlighted with a red cross after the clean attempt.
I have just had this problem and it was because I had created my own folder called 'data' within res folder. After the clean it had a little red cross against it. I removed this folder and R built again.
Regards,
Mark
Several things you should check in your project:
Check the Problems tab in your Eclipse IDE. Are you sure that you did not introduced building problems while making changes with drawables? To check that you need to check xml source of affected layout and see if something is marked red.
In File explorer go to the directory where your Android project is. Check that you have file default.properties (.classpath, .project and AndroidManifest.xml should be there). If default.properties is missing it may be easily replaced by correct version.
Which is the Android version you are working with? If that is 1.5 or lower be sure that in the res directory you have directory named drawable, not drawable-hdpi, drawable-mdpi and drawable-ldpi. Last three are valid for version 1.6 and higher.
Right click on your project in Package explorer in Eclipse. You will get a number of options. Go to Android Tools-> Fix Project Properties so see if that helps.
I had an invalid jpg in my res/drawable folder. I removed the jpg and it worked.
I had this problem on my Mac too and I think it could be good to know for all Mac users how I managed to solve this error.
I had a .DSStore file automatically imported to my project inside the res directory and when I removed it and rebuilt the project all went well.
Everytime you clean the project and it rebuilds, it imports
import.android.R
so, delete this import and remove all errors from xml files. It will work.
This happens to me if I move my project to a new location. I have found that the answers above didn't fix my problem, but that creating a new project and importing the source did.
This may be simple but check to make sure you don't use
import android.R;
If you add an external resource file with capital letters for example
"Hello.png or WelcomeSound.mp3 etc etc" like if you add upper case letters and clean your project you'd surely loose your R.java file. So if you already lost it, either rename the file externally and then clean your project or else right click on the project Refractor->Rename and then rename your file with all letters in lower casing. Next, delete the 'gen' folder in the project explorer and now right click and "Build Project". If Build Project option is grayed out, go to Project-> Deselect "Build Automatically" option.
Regards,
Kshitij Thube
Check at the Console View If there in message Error, It will Help you to find out the source of the probleme.
I had i similar probleme and i find out that the probleme was from the pic name even if the name respect the Syntax so I change it to img1 and it worked fine.
Try editing one line of code in your project, then build the project once more.
Another thing: never try to run an application with the texteditor opened with a xml file. That will create a wierd run configuration that can only be fixed by project clean-up and sometimes can make the xml file to vanish (happened to me twice already).
All my R.* files stopped working after I did a Project->clean in Eclipse. The issue was that I backed up a XML file attached to one of my activities in the layout directory. This causes errors in every activity of my project.
After deleting the file I still had R errors in one of my Activities and it only was resolved after I tried importing different files and then deleting them. I actually made no change to the previous imports but for some reason deleting them all and re-pasting them fixed it.
I have got the same problem after lots of cleaning and building project again and again. I found that on console there is this error:
res/drawable-hdpi/Blue Blank.png: Invalid file name: must contain only [a-z0-9_.]
and this is not appearing as an error in xml. I changed the name and save the file, clean project and build. Now it's working. My suggestion check your res folder and name of files you use in it and name only [a-z0-9_.].
Delete related tag in xml, save xml, clean project, build project. Now again put that resource in xml and save!
Check your file in drawable folder ensure that all are resource file (image) remove unwanted file Like thumb.db. Remove those all files and check again
Make sure your png files have lowercase names. That is what kept throwing mine out, because I capitalized the first letter, or I used an unallowed non alpha numeric in the naming. Check that before destroying any of your code.
just check your image folder (usually created res > drawable files) and be sure dont use capital letters on .png files, every type must be in small letters then you can find again your R.java under the gen file folder
i removed 'import android.R;' then commented out the offending lines, then did a build, ok
then i removed the comment and it fixed it
I had the same problem when I cleaned my project. I got crazy to solve it, I searched and searched but solved it in my way.
First of all, delete all needless files in your /res folder. I had some notes in it, I took them to another project that I don't work on it and build the project manually. It worked! Try this I'm sure it will help.
Good developing!
Was there an XML file with the naming convention of "somthing.out.xml" generated? If so you should delete this file (an unwanted file of this name can cause major problems for your somthing.somthing.R file import).
In some versions of eclipse (I know eclipse javaEE does this for sure), running the project while viewing an XML file will create a file called filename.out.xml in your res->layout folder. You must delete this generated file if this has occurred otherwise you wont be able to get the java.R file to import.
Try Project -> check Build Automatically
If you are using 64-bit Ubuntu, try to install the 32-bit libraries (ia32-libs)
$ sudo apt-get install ia32-libs
it worked for me
This exact same thing happened to me. coincidentally I needed to update my adk that day, so i did so and after restarting eclipse it worked again. My recommendation would be to build the project and restart eclipse. It is not due to any error in your code.
I read and tried many of the above after simply doing a clean on one project. Eclipse would not build anything afterwards.
Fortunately I had last-nights backup of the workspace and my source is copied in from VS 2010.
No more cleaning!
Delete your project from workspace witout source deleting and then import it into workspace.
RightClick on your Project -> Delete /Don't select "Delete project content on disk (cannot be undone)"/ -> Ok
File -> Import -> General -> Existing Projects into Workspace -> Brouse -> /Look for your workspace(!) folder/ -> Ok -> /your cleaned project will be automatically checked/ -> Finish
I had the dreaded missing R problem yesterday with Eclipse Juno after a routine clean. StackExchange is full of suggestions and extensive googling revealed only the usual suspects (XML naming conventions problems, etc) none of which seemed to apply directly, although it is certainly possible I missed something.
The best summary comprehensive list of possible causes and fixes was here:
http://www.techrepublic.com/blog/software-engineer/a-comprehensive-troubleshooting-guide-for-androids-r-cannot-be-resolved-error/
One useful tip there was to try to create and run a simple "Hello World" in my workspace. If that does not run, the setup is corrupted. My Hello World was just as full of errors as my custom app.
The solution that worked for me (perhaps great overkill but nothing else worked) was to completely uninstall Android SDK and delete Eclipse (Juno), download Eclipse for Developers (Kepler) and reinstall Android ADT plugin and ADK and recreated my AVDs using the latest "compile with" version in options.
So far so good, although I am recreating the app from scratch. I will be more cautious about using clean from here on.
I have same problem occur just now I renamed invalid png file like *demo.1.png as demo.png * and its work.
Proven successful method, check the file (AndroidManifest.xml) and delete all comments in it, and make sure there are no errors in this file, I tried and did work with me.