Eclipse hangs when trying to add menu.xml - android

I've recently starting developing with the android sdk. Currently, I am trying to add code to use a menu, however, when I try to add a menu.xml under res/menu, Eclipse hangs and freezes every time. When I reopen the Eclipse, menu.xml is there, but every time I try to open it, Eclipse hangs and freezes again.
I am running on OS X Snow Leopard, Eclipse 3.6.2 and the latest android sdk and adt plugin.
Any help, insight, thoughts?? I am thoroughly stuck.
Thanks.
Dustin

Thanks for the input guys. What ended up working for me was instead of trying to manually create a new menu.xml file, I find the add android .xml wizard and using it instead allowed me to add whatever I needed with out any hang ups.

Same problem happens for me even under the latest version of Eclipse (Helios). If I wait long enough, Eclipse reports a stack overflow exception and then this shows up in the Output window:
W/ResourceType( 5124): Bad XML block: header size 0 or total size 9949440 is larger than data size 0
menu.xml:1: error: Error parsing XML: no element found
This indicates that the XML parser isn't handling empty documents and the Android menu editor is barfing on the newly created file while trying to open it. I'm sure there is some "standard" way of creating a new menu that doesn't break the IDE but I have no idea what that method is. I'm too used to editing my files by hand but this crash/hang bug is a serious nuisance.

Dustin,
I think what has happened is, your settings have become corrupt. I highly recommend resetting all your settings. Keep in mind, you will have to re-import all your projects so this can be quite a pain, but I really think this will fix your problem.
To start, find your workspace folder and rename it to something like "workspace-bad"
Then, create an empty workspace folder to replace the one you just renamed.
Lastly, open eclipse and it will act just like a brand-new installation.
You will need to re-import your projects, which can be done by going to eclipse, hitting File>Import...
Then select under General
"Existing Projects into Workspace"
then hit "Next" and then hit "Browse" to find the root directory
also make sure "Copy project into workspace" is checked
I also recommend doing your "problem project" first, that way you don't waste your time doing the rest and then find out you have to re-create it.
I'm hoping that fixes it for you, good luck! :-)
-Jared

I ran into the same issue with the same setup. Right clicking menu.xml, selecting 'Open With', and selecting Xml Editor seemed to be a viable workaround for me.

Related

Android Studio Inspections doesn't work correctly

When I run inspect on my code it shows a warning like this:
Property "isLoading" is never used
Even though I am using that property. There are no problems with code, everything works fine, but this issue annoys me, what should I do?
You can see both warning and usage of that property in the photo below:
If the answer above doesn't work,
Go to your local drive -- Users -- Android Studio -- System
and delete the caches folder, then open android studio.
Go to file -> Invalidate Cache/Restart
Click on Invalidate Cache/Restart, a menu pops up
On the menu, click on Invalidate Cache and Restart
// Wait for android studio to restart.
I made an enormous mistake. I assumed Android Studio knew what it was doing when it said it found unused resources and I let it remove them all. It removed much needed XML id tags, it removed drawables, launcher icons.... what a mess. Has no one in Android studio land addressed this egregious set of errors? I spent a far too much time undoing all the things "Inspect code" said was wrong and I let fix only to find the app fails.
Lesson learned - never assume Android Studio knows what it is doing when it comes to inspections. Always check each before taking their often erroneous suggestion

Why "Remove Unused Resources" doesn't find anything in Android Studio?

As you might know, Remove Unused Resourceshas added recently to Android Studio, Android Studio 2.0 Preview 5.
I run this function by right click on the name of project then Refactor/Remove Unused Resources. It shows a dialog and nothing happens when I click Refactor or Preview buttons. I believe there must be a lot of problems since this is a very big project but I don't see result. Are you able to see any result?
Okay, I just found what is the problem.
The problem was, as I mentioned I was right clicking on project name and did refactoring from there. So this way doesn't work (Android Studio guys must disable this functionality to not staffing people around)
So, By running Analyze/inspect code I could see a list of unused resources. I doubled clicked on an String item then String.xml opened and by doing refactoring/remove unused resources... all resources removed :+1
So it was the trick. I could see all changed files on git. Hope it helps you guys.

Android application problems in Eclipse

I'm a .NET developer but I like JAVA so in my free time I play around with that. I don't normally use Eclipse but I installed the ADT eclipse plugin and Andriod SDK and I started learning and I made a new project with a TableLayout and it kinda looks good, and it runs ok on the emulator.
However... there a few things that drive me absolutely catatonic and perhaps I am doing something wrong so please help me out.
Firstly, if I change the main.xml file in whatever way, even by adding what is supposedly a correct parameter, it will start freaking out and will generate an error that just says "error" without specifying what that is, it will then generate a main.out.xml and then report an error that the main.out.xml is empty. It later won't let me delete that and will start generating a main.out.out.xml and so forth, even after I correct that original xml that caused the error.
The only way to get things going is to delete the bin folder, restart Eclipse, delete all the out xml files and then sometimes it will run the application or some other times it will start generating those 'out' files again and the loop goes on.
That way it takes hours to run a simple app even one without errors that used to run before.
Surely that was NOT how they intended it to work, is it??
Also.. there is no "Rebuild" button that will flush all files out automatically, or is it hidden somewhere? I am tired of manually deleting those automatically generated files and the build folder and all those out.xml files.
Also, while I'm at it, I also want to point out that the designer view sometimes disappears and there is nothing on earth that will bring it back, the only way is to create a new project and copy the main.xml to it and then it shows up again. Another bug?
I have the latest eclipse version:
Version: Indigo Service Release 2
Build id: 20120216-1857
If you have any clues how to get this to work, I will appreciate it!
Many thanks in advance
When you click the Run button with an XML file selected, Eclipse is running an XSL Transformation on that XML and producing the .out.xml file as the result. This is a feature of the Eclipse Web Tools feature, which you'll have if you installed the Eclipse for Java EE Developers package (it may be included in other packages, too).
As others have said above in the comments, to run your Android app, select the Project, right-click, and choose Run As > Android App. Once you've done that once, it will create a Launch Configuration that you can launch from the Run or Debug toolbar buttons (pressing the small down-arrow on the Run or Debug buttons brings up a list of Launch Configurations that you can select from, as well as an option to manage them).
There is a Preference that will make Eclipse always launch the last thing you ran or debugged, instead of trying to be smart about what is currently selected. Open the Preferences and navigate to Run/Debug > Launching; there you'll find the option under Launch Operation at the bottom of the window.

Android: Graphical Layout not working - doesn't show anything

My situation is: I once made an android project(2.2 version) but soon needed to format my computer. After formatting, I downloaded eclipse again but when I imported my project, I wasn't able to use the 'graphical layout' menu for xml. It doesn't show me anything like the picture below.
http://img525.imageshack.us/img525/3586/19978552.png
I cleaned the project and updated the Android SDK, however, none of these seemed to work well. What could be causing this?
Try restarting Eclipse. Usually that solves the problem for me when that happens.
Right click on your layout xml file and select Open With -> Android Layout Editor. It will force eclipse to open file in android's layout editor mode
None of above worked for me. what worked for me is:
1- Select a Google APIs Project Build Target rather than one of the Android X.X ones. This setting is in right click on project -> Properties->Android.
2- Make a change in XML and save it. Now switch back to "Graphical Layout" and it will show the layout.
For some, only 2nd step works.
This Question was asked 3 year ago, I am sure that you have get your solution, however i was also facing the same problem but got the solution in eclipse, here it is:-
1)Goto help->AboutEclipse->Installation details.
2)check the version of Android DDMS, Android development tool, Android hierarchy viewer, Android native development tool, Android trace view and tracer for openGl ES in installed software tab.
3)If they have different version than you have to update all of them.
4)Goto help->check for update in eclipse and follow the instruction.
5)Then restart eclipse.
This solve my problem.
The topic seems a little bit cold, but I wanted to add it nonetheless.
I had a similar problem with my layouts recently. When i create a project it automatically creates the layouts in the latest version of Android (eclipse shows it as version 22 of android as of today). But i can't see anything. So i just change the version to, say 18, and it shows ok. Furthermore if i want to change it back to version 22 it throws and exception, saying that a class can't be instantiated. (I am probably missing a class or a library on my system.)
Therefore if you cant see the layout it might be a good idea to switch back to earlier versions for development. cheers.

Content Assist not working in Eclipse for Android

I've been working in Eclipse programming for Android for about a year now. I suddenly have an enormous problem. Here is the error:
"Content Assist" did not complete
normally. Please see the log for more
information.
java.lang.NullPointerException
I go to Help>About Eclipse SDK>Installation Details>Configuration>View Error Log and it is nothing but a blank page. No errors at all.
I tried researching online. The most relevant pages I could find are http://forums.adobe.com/thread/455543 and http://www.themorphicgroup.com/blog/2009/10/27/content-assist-did-not-complete-normally/ and http://www.airtightinteractive.com/2010/01/fix-for-flash-builder-content-assist-did-not-complete-normally/ . All of these pages say to close FB, delete the .metadata folder,restart FB, import/export some SWC file, and/or delete some file with "flexbuilder" in it's name. None of these work and I see nothing on my whole machine with any of "Flash Builder", "FB", "flex", or "flexbuilder" in it's name.
As a desperate last resort I deleted all traces of Eclipse, Android, Adobe anything, and Java from my machine.
Absolutely no difference what-so-ever. Besides exhaustion and heartache for me.
The content assist features seem to work fine in java files (for now anyway). It seems that only .xml files are affected.
What can I do to resolve or work around this issue?
Make sure the correct editor is opening the xml files. I have aptana and some other plugins that support xml files. Right click the file in project explorer and select open with, then select Android Xml Editor and see if you have completion.
I dont know if that is the exact name, because my eclipse just went south and wont even open :)
Right clicking the file and opening it specifically with Android Layout Editor is what solved the problem for me. Eclipse will continue to open it up with that editor after choosing that editor.
Uninstalling and re-installing the Android Developement Tools Plugin for eclipse at least partyl fixed the problem for me.
Strangely it worked best when completely uninstalling the plugin!?

Categories

Resources