I get a null pointer exception opening about half of the android XML files in my layout directory. There seems to be no pattern to why some files open and some files don't.
I upgraded eclipse to Juno. Re-installed all the plugins (ADT), re-installed the android SDK. I brought in my old workspace and adjusted my projects to point at the new android SDK.
Stack
java.lang.NullPointerException
at com.android.ide.eclipse.adt.internal.editors.layout.configuration.ConfigurationComposite.setLocaleCombo(ConfigurationComposite.java:1566)
at com.android.ide.eclipse.adt.internal.editors.layout.configuration.ConfigurationComposite.syncRenderState(ConfigurationComposite.java:3049)
at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.activated(GraphicalEditorPart.java:1158)
at com.android.ide.eclipse.adt.internal.editors.layout.LayoutEditorDelegate.delegatePageChange(LayoutEditorDelegate.java:679)
at com.android.ide.eclipse.adt.internal.editors.common.CommonXmlEditor.pageChange(CommonXmlEditor.java:359)
at org.eclipse.ui.part.MultiPageEditorPart.setActivePage(MultiPageEditorPart.java:1081)
at org.eclipse.ui.forms.editor.FormEditor.setActivePage(FormEditor.java:607)
I found one way to resolve this. My eclipse recently crashed (and wouldn't start again) for an unrelated reason. To get it to start again I deleted most of the files in ${workspace}/.metadata/.plugins. These files regenerate (but will wipe some of your saved plugins and settings). Resolved my startup problem and my xml editor problem.
Just close all the xml files and restart your Eclipse SDK
An additional solution that worked for me and might work for others:
Create a new workspace and import your existing projects into it. I felt a little better about trying this than I did blowing away or moving my .plugins directory in the existing workspace. After I created the new workspace and imported the project that was giving me the cryptic "Failed to create parts controls" message, it worked fine. I'm pretty sure it's something bad in the .plugins or elsewhere in the old workspace, but I'll just keep using this new one until it starts to crap out on me.
Note that this can also happen if the containing folder contains too high a resolution
Example:
layout-sw500dp (this folder works okay)
layout-sw1000dp (this folder causes "Failed to create the part's controls" error)
I finally found out...
I had the problem even after deleting and setting a new copy of eclipse. The problem was because of the wrong Java version. You should find the right Java version for your eclipse.
In my case I have a project which uses Java 8 and for that I use eclipse Luna. But my other project which I develop it vie eclipse kepler uses java 6 (The project with the problem!).
Since Kepler and Java 8 are not compatible, I got this weird behavior from kepler. As soon as I ran Kepler via Java 6, everything was back to normal.
If you wanna know how to sets different Environment Variables and sets your Windows Path without setting up the Environment variable everytime for each project, let me know, I would be happy to share how to write a batch file to do that...
Related
The title says most, but I have created a new project in Eclipse. I have everything set up, and as soon as I create a new Android Application Project, once everything has Generated there are 2 Errors: both "R cannot be resolved to a Variable", on Line 19 and Line 12. In the Video Tutorial Series I am watching it says there should be a file called R.java in the gen folder, but there isn't, just an empty folder. The Android project is completely new. Here are some of the things I have tried after googling, none solved the Issue:
Clean Project
Uncheck/Re-Check Build Automatically
Build Project
Close/Open Project
Check XML files for Errors - only the Two Errors as mentioned above in the Error Log
add "import android.R.*"
Create R file manually (Add -> Class)
It is my first time writing an app in eclipse, I know there are a lot of questions like this but none seem to solve my problem. The Java Errors (R not resolved to a variable) Errors are the only errors, no errors in the XML or Anything.
So that you can check my project, I have put it in my Dropbox if you want to have a look at it in eclipse.
Project Download Link
You can create the new Project and then copy the contents of this project into the new one.
This problem is with Eclipse. I recommend you to use Android Studio.
What might help, would be to create a new project and transfer the current project to that one. When the R file is not created when creating a new project, try and re-download the development tools and sdk.
I'm sure that the problem may be with your ADT tools in eclipse. Sometimes, this errors may occur due to some installation mistakes or some sort of software cracking problems. I also faced the same problem at my starting stage. The best thing that you can do is to move on with re-installation of ADT in you eclipse. It may help you. Try this!! Create you new Android Project and Enjoy buddy !!
I was having this exact problem, and found the solution after much headache.
In eclipse, find and click the button labelled Android SDK Manager (next to save, and all that jazz on the toolbar).
In the manager, make sure that under the "Tools" folder all of the relevant "Android SDK Build-tools" have been installed. Once they are, restart eclipse, and your R.java file should be generated. Hope that helps!
Every time I open Eclipse, I get the following error messages:
Android SDK Content Loader:
parseSdkContent failed java.lang.NullPointerException
Initializing Java Tooling
An internal error occured during: "Initializing Java Tooling". java.lang.NullPointerException
Loading data for Android 2.2
Parsing Data for android-8 failed java.lang.NullPointerException
Loading data for Android 2.3.3
Parsing Data for android-10 failed java.lang.NullPointerException
Loading data for Google APIs (Google Inc.)
Parsing Data for Google Inc.: Google APIs:8 failed java.lang.NullPointerException
See link for screenshot:
http://i.stack.imgur.com/lhhQQ.png
(I am using OS X Lion, and Eclipse Helios)
First i read some posts saying that it was the AVD.ini file in the .android profile that was causing the trouble. I tried deleting all the entire .android profile folder as suggested in Android SDK Content Loader failing with NullPointerException. This didn't correct my problem.
I tried deleting the entire Android SDK folder, downloaded it again and installed a couple of Android versions through it. Still the same error messages...
To ensure that I didn't have any old plugins or something that were the issue, I uninstalled eclipse, downloaded it again and installed the Android plugin again. (So the plugin is up to date).
When I go into one of my Android projects, I get error messages on places where I acces resources by using the R file. Regular Java projects work fine, but all Android projects gets small red boxes with white crosses on them. I have been searching for a solution to this problem since yesterday, but at this point I'm completely qlueless and would appreciate any help I can get!
Close all open projects and exit Eclipse. Now you can open Eclipse without getting the error. Start opening your projects one by one to find which one causes the problem. This is most likely because you deleted a Device profile inside the AVD manager.
Do not delete all the full .metadata
Backup .metadata
delete only .metadata/.plugins/org.eclipse.core.resources/.project
restart eclipse
Observation : the projects folders are created
Further - if you are using svn/git/hg have code repository links it would be destroyed, so to reinstate
close eclipse
copy relevant projects from backup to merge with current projects in .metadata/.plugins/org.eclipse.core.resources/.project
restart eclipse
Downfall - sporadic fail error may occur (sync or something) - harmless
backagain
I encountered exactly the same issue this morning. This is a workspace related issue.
Solution 1
I looked into my .metadata and read .bak_number.log files . Some layouts failed to parse and my projects were out of sync with the file system.
So I deleted all the .bak_number.log files. Relaunch Eclipse and the whole worskspace should work again the way you left previously.
Solution 2
However if it's not due to out of sync with the file system. Change the workspace then import all the eclipse projects from the previous workspace.
Thanks the project.properties files , the dependencies are still kept.
PS : I should return to IntelliJ :)
first close your Eclipse
Go to your workspace and rename .metadata to tushmetadata and go to
tushmetadata- >.plugins -> org.eclipse.core.runtime -> .settings
and copy all files from it.
now open the Eclipse and go to your workspace there you can see the
newly generated .metadata folder in that go to .plugins ->
org.eclipse.core.runtime -> .settings and paste here and do not
overwrite any file.
Try to "Hello World" project and run it.
Try to delete file .metadata from your android workspace folder. .Metadata folder contains all configuration files for eclipse. It works for me.
Your answers might be right. What I did was to change my workspace. I redownloaded the project I was going to work on from git, and reimported it. Now it works fine :) Maybe there was some files in this project that made the error messages apear? Dunno....
I have remove the .metadata folder but after it, when I run the eclipse, I cannot creates any Android project. To solve it, I have done the follow:
Go to the main work directory of eclipse
Localize the folder com.android.ide.eclipse.adt It should be in .oldMetadata/.plugins/
Copy it to the new eclipse configuration: .metadata/plugins/
See the full solution here:
http://www.jiahaoliuliu.com/2011/06/running-android-sdk-in-eclipse-errors.html#solution4
For me, the source of the NullPointerException problem was a host-side Junit test project that references (and tests) code from an Android project. It didn't have a project.properties file. It's not an Android project, but for some reason the newer versions of the SDK somehow expects the file there. To fix the problem, I just copied a project.properties file from an Android project to the host unit test project.
When I met this problem about a year ago, I had some projects in my workspace that needed a specific Android SDK level (let's say 2.1) and i didn't have it installed in the Android SDK.
slott's answer helped a lot. Deleting the .metadata or reinstalling eclipse didn't though. The trick was to isolate the project causing the problem, delete its .settings folder and .project file and reimport it.
I discovered another cause, where I'd added a space character into an otherwise blank line in the project.properties file. When I eventually ran android update project -p .
the program (android.exe) threw a NPE exception. When I deleted the space from the blank line the android update project command worked and eclipse started behaving (after running clean a few times).
This happened with r20 of the Android SDK on a Windows 7 64-bit machine.
FYI my change that fixed the problem in project.properties is public at http://code.google.com/p/android-daisy-epub-reader/source/detail?r=517
This is just weired.
In my case when I took a subversion update, I was getting this problem. The reason was the corruption of my project.properties file (due to subversion conflict).
I just corrected the file and problem got solved.
I found it's just missing project.properties file in the project folder. After copying one from another project the error is gone. The only valid line in project.properties is
target=android-8
If you are using SVN or GIT please check whether the project.properties has conflicts or not.
Sometimes project can not be open because of this.
I hope this is useful to someone and saves his/her time: My colleague was facing same issue and we did almost everything mentioned here, with no luck. In the end we changed the Android SDK version in the manifest file and it worked.
This solution worked for me.
Close Eclipse and delete all .markers inside your workspace folder.
Restart Eclipse (once I had to restart it twice, it hang on the first but worked on the second for no aparent reason).
Of course, it's always safe to back them up first.
It is stuck in cleaning output folder for “Project”. It is not always the same Project. So is there some workaround ?
I tried the method of cleaning the project, but the library update happens too fast. I even assigned a custom keyboard shortcut to Clean and I still couldn't get it in there before it started.
I really didn't want to delete the .metadata folder because it is a pain in the arse to lose your workspace settings/preferences/setup.
So I tried:
Make a copy of the .metadata folder
Delete the original
Launch eclipse (it will open with a default/reset workspace), but it will open fine.
Quit eclipse
Delete the new .metadata folder
Make another copy of your original copy and rename it .metadata (basically put the original back)
Eclipse should now launch fine. In my case the Android Library Update still ran but it actually finished within a few seconds instead of hanging.
Then for me the underlying issue was one of my library projects got into a really broken state. I went into the properties for it, unchecked isLibrary in the Android tab and then refreshed the project. Afterwards I turned the library flag back on and did a clean.
I also had a build error in the library code that had to be fixed.
Any how, hopefully that helps if you find yourself in a similar position. Good luck!
So while I asked this question I found workaround for me , and possibly for others. You have to kill eclipse and on next start , do clean up on all projects before eclipse start that “Android Library Update” task and it will not stuck eclipse.
Deleting the .metadata folder works to get Eclipse back up and running, but after importing Android projects into the workspace the problem came right back for me.
In my case the underlying cause turned out to be the "Android Library Task" being stuck on trying to access the network. I'm connecting to the network via a proxy, and despite being configured in the global OS network settings and all other applications working fine, Eclipse was still unable to access the network. The only thing that worked was, after deleting the .metadata folder to get Eclipse running, manually entering the proxy configuration in "Preferences->General->Network Connections" to match that of the OS network settings.
Now the "Android Library Update" takes a second on startup instead of getting stuck.
In my case the other mentioned methods did not work for me
but "Reinstalling Eclipse and its all plugins" related to my project did.
After doing that it came to the normal state.
My env;
Eclipse Juno (under OS X Mountain Lion)
GWT
ADT
SVN
Another trick that works is to kill Eclipse, delete the ".metadata" folder from your workspace and restart Eclipse.
It'll force your workspace back to its initial state and clear up any hung conditions.
Since installing Eclipse 4.2 I have had to resolve this problem twice. The second time I knew that the only thing that worked for me was to create a new workspace and import the projects from the "broken" workspace. It is very fast and is a good opportunity to de-clutter by leaving obsolete projects behind.
Specifically,
choose File/Switch Workspace/other and put in the name of your new workspace.
Then right click in the Package explorer of the new workspace and choose Import and select Existing Android Code into Workspace.
Then browse to the root of a project that you wish to import and also select Copy projects into workspace.
Hit Finish.
You will have to do the same for any projects that this project is dependent on such as google-play-services.
Recently experienced this, caused by an Annotation Processor throwing an uncaught exception. Killed Eclipse, removed references to the offending Annotation from one project .java file, and started successfully.
In my case, within Eclipse, I had set up a C/C++ Builder to invoke build_native.sh, which is needed to build cocos2d-x. Interestingly, the Android Library Update indicated that it was invoking build_native.sh ! For me this explains why it was taking so long sometimes and seemed to be taking a LONG time to finish. I basically replaced this with an echo command. echo "do nothing" and I think this resolved the hanging issue.
This seems pretty goofy to me -- AFAIK, there's no way to configure 'Android Library Update', and I'm not sure why it's doing what it's doing, since Eclipse has a number of build options which the user can manually control.
I am a very beginner in android development using eclipse..
I have given an assignment to modify the android application made by a professor..
so I downloaded the file and imported it to eclipse.
My professor can normally run the program..
however, when I tried to test it before modication using simulator, " the application is forced to stop unexpectedly" is shown..
Moreover, I found that all .java file in src contained "x" ...and the codes in the .java file, like "import android.graphics" or "private class xxx" all contained error..which i have been told that "import andorid.graphics" cannot be resolved..
Could anyone tell me what's wrong with the codes...
and kindly provide me the procedures to fix this problem?
is it possible for me to send the zip file to someone..so that he/she can help me find out the problem??
Make sure the Android sdk and ADT are configured properly in Eclipse and you have updated the relevant packages using SDK Manager. Best way to test this is to create a HelloWorld Android app
http://developer.android.com/sdk/installing.html
Assuming that you have correctly installed the same Android SDK that your professor is using, the first thing to try is to right click on the project name, then select Android > Fix Project Properties.
I've often found that importing existing Android projects into a workspace can be problematic, especially when the project comes from a different machine. A work-around is to create a new Android project, then copy all the sources and resource files into the new project. It's a pain, but it avoids many problems that arise due to different development configurations.
have an odd one..
Using Eclipse Juno, and everything was working fine for the last couple months. At some point yesterday, while Eclipse was cleaning my project, something crashed - popped up the Windows error reporting. (Didn't catch the name of what crashed..)
Now, I have no R.java class in /gen, and nothing I've tried will generate it. On top of that, when doing a clean rebuild of the project, the Output window remains blank. (No errors, no status message.. nothing.)
Tried just about everything - including the latest which included reinstalling Eclipse and then ADT. Still hadn't helped. (I have NOT tried clearing the workspace metadata yet, will do that soon.)
Any thoughts on what else to check?
--Fox.
Edit: Updating a random file - either .java or an XML layout/drawable does not have any effect, still nothing. Also, removing saved preferences from workspace .metdata data didn't have an effect either.
Edit 2: Okay - not sure WHY it was happening, but creating a new project and the issue was corrected.
So somehow either the project settings (.settings or project.settings) must have gotten corrupted. I have the origianl project still, and am curious to see why it happened, but creating a new project and copying sources and resources over, and no more issue.
Thanks to all that offered comments - goes to show that any kind of little corruption can cause strange things to happen.
The reason in 99% of the cases is that you are missspelling something in some xml file.
The R class file won't appear until all xml files are correct.
I suggest look carefully into your XMLs for a very small syntax error.
Or try taking off 1 by 1, until you figure it out wich one is the problematic.
:) kind of annoying, i know.
If you don't have any errors in your xml files, you tried to reboot your eclipse, your emulator, then open the sdk manager and apply all update. My R have finally been generated.
I found this happened after updating my Android SDK Manager and related eclipse plugins. I am running in Ubuntu, and it would not let me update the plugins unless I ran as the root user (using "sudo eclipse")
This left some of the Android SDK Manager items, and the eclipse plugins, owned by root. This stopped the "clean" working on the project - it must have been something that had been added as the root user, and not accessible as my normal user.
I had to "chown" my eclipse directory and my Android SDK Manager directory so it was owned again by my normal user:
cd /home/myacct/android-sdk/
chown -R myacct:myacct *
After this the clean option worked, and R was regenerated.
This was it for me:
In your AndroidManifest.xml file, make sure that you have the SDK installed for the version number in android:minSdkVersion="##".
You can install SDKs from the Android SDK Manager, found under Window -> Android SDK Manager in Eclipse / ADT.
For me it ended up being gen/com/(appname)/R.java missing.
Not in my recycle bin, not anywhere... just took a surprise vacation and never returned.
I had a backup copy in a different folder. Copied it back and all's good now