i want to change my sdk path in android adt? - android

a few days ago i have lost my R.java file from my android app app project from android adt while cleaning it...as it was showing some errors when i was trying to add the feature of ads in my xml file...now i am unable to recover my R.java file in the project .
I have tried many options such as:-
cleaning the project .
checking for errors in the xml file and corrected and tried to clean the project once again.
copied and pasted the res,gen and android manifest.xml file in the new project of the same in another workspace and pasting the new R.java file generated over there into the actual workspace but still its not working and showing errors.
i tried to cut and paste the sdkmanager.exe from the actual folder to some folder elsewhere and tried to clean the project again to regain its R.java file but it is still not working and the sdk manager is showing the same path even though i have shifted it somewhere else...
now what am i supposed to do...

To change SDK path: Window/Preferences/Android.. and then Set SDK Location

R.java is an auto generated file and it's error is based on errors in Manifest file or resources , maybe there is an unnamed string in your string file ,if you can, post your R.java file errors. and for changing sdk path its through Window -> Preferences - > Android .

On Windows : Window > Preferences > Android. Then click on "Browse" to change SDK path.
On Mac : ADT > Preferences > Android and "Browse"

You need to provide your R.java file errors mine was R cannot be resolved to a variable and I had to go to project properties -> java build path, then make sure your libraries are selected and clean and build and if that doesn't work delete your bin and gen folder and clean and build...Hope this works for you good luck!

Related

Project has no project.properties file When creating a new Android Project

I just installed Eclipse on my Mac, I downloaded the bundle that provides Eclipse+SDK, I've also downloaded all the needed updates but when I create a new project I get the following error:
[2014-08-25 16:51:02 - provaApp] Project has no project.properties
file! Edit the project properties to set one.
I've tried everything found here on SO but none of the answers worked, I really have no idea on how to fix this. I've also deleted and downloaded Eclipse twice.
Edit: I get also the following error if I try to edit the properties of the Project by right-clicking on Project Root folder > properties > Android
If I try to set the project build target (in my case Android 4.4W) I can't because it doesn't save the changes.
What I know works is if you create a new blank project, copy that project.properties file into the existing project and it should work. Also try running a clean project sometimes helps, but very rarely.
It's a pain but luckily this happens rarely.
Try to create a project.properties file with this content:
target=android-19

Cleaned the project and r.java is not generated

I have a project i used that worked fine, then i replaced a java file(class) with file from some other java project(had extra code in it), and also the strings.xml and some of the layouts.
and now this class dont recognise some of the new xml id's, even though i double-checked and everything seemed ok and hit "save" on each of the files. I tried to clean the project and it made the R.java file disappear for good.
I checked the answers in:
Developing for Android in Eclipse: R.java not regenerating
But nothing helped me.
The XML files have no errors, and i didnt changed the manifest file.
Only replaced a .java file and the layouts.
What else can be the problem? It is the second time it happens to me while trying to "import" others files to my project.
restart, clean and rebuild your application in android studio or java application help. If you are using android studio then, You can also try to sync project files with gradle file.
should be under tools --> android --> sync project files with gradle file in your android studio.
try clean your eclipse using terminal. cd to your eclipse directory. Mine like this
cd /Applications/eclipse_juno/Eclipse.app/Contents/MacOS
then clean
./eclipse -clean
done

eclipse, set up android application

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.

R.java deleted automatically: Android

When I changed some design in .xml file, R.java file automatically deleted. How can I get back that file and what is the solution to resolve this problem, that in future this problem does not occure.
check all your errors in xml files structure (layouts, string etc...) even if sometimes they are not easy to spot.
My advice is to undo the latest things you've done until you find where the errors were and fix them.
Once they are all fixed the R file will be created again (maybe you need to clean your project: project -> clean)
In the future just try not to break the xml files and this won't occur again xD
You can also disable automatic build in your Eclipse IDE(Menu -> project- > Uncheck build automatically). This way the R file will be recreated only when you manually build the project and not when you save changes in an xml file.
Fix your errors and the R.java file will return...e.g when i added an image in my resources folder its name was in uppercase....when i changed it to lowercase,immediately after doing it my R.java file returned...its all due to errors...just fix them and it will return
I agree with #maid450.
I also have faced similar situations.
If your problem isn't resolved after all this, ultimate option is to create a new project, and copy files to it.
one solution is that Go to Eclipse project tab -> uncheck Build Automatically -> Clean the project.Make sure that there is no error in your project also don't try to edit the R.java file one it will created. Then manually build the project. you will get the r.java file.
The best solution for Mac/Eclipse user is to go to the SDK Manager and re-install the Android SDK Build-tools, and then restart Eclipse.
For some reason after performing a Clean action on a project the R.java file for all projects happens to be deleted from the system.
Clean the project.
Menu [Project] -> [Clean...] -> Select you project -> [OK]
Project will rebuild automatically, if not, chek
Menu [Project] ->[Build Automatically]
The R file deleted automatically when I changed my activity_main.xml in Android Studio.
What I did was copy the R java file from another project and paste it into the project in which it got deleted.
Hope it helps. :).
Location for R file.
Project/app/build/generated/source/r/debug/com.android.'projectname'/R.java
Where is the R.java file in Android Studio?

Missing AndroidManifest.xml when importing an old Android project into Eclipse

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!

Categories

Resources