Android application problems in Eclipse - android

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.

Related

Android Debugging wont work XSLT error

I ran my program just fine a few minutes ago, and when I added more functionality now it is telling me "The JRE Instance Default XSLT processor does not support debugging_ Would you like to debug using the default Xalan 2.7.1 processor instead?"
I did restart Eclipse maybe that has something to do with it? :/
It's my first times writing an app so if I have to set something in eclipse each time maybe that's why? and what is it if that is the case.
Thanks!
You were in an XML file when you hit debug, I would bet. Happens to me all the time. For some annoying reason it does something entirely different that I don't understand when you do that. Delete the .out.xml that should probably have been created, open a .java file, and try to debug again. Another way is to just right-click your project and do Run As > Android Application.

Eclipse hangs when trying to add menu.xml

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.

Android Apps wont update

i know that eclipse has a couple of glitches when it comes to updating your app and running it on the emulator, i have tried everything that i have found on the internet. Stopping the adb manually making a new emulator and starting it with "wipe user data" and restarting it even reinstalling all of the programs. What i have noticed is that it updates correctly until i start adding images to the drawable folder. After that it doesn't update at all. Can anybody help me its really frustrating also the pictures show up on the "graphic layout how they are suppose to it just doesn't update.
When you add images/resources to the project Eclipse sometimes (always?) doesn't realize anything changed. So then when you run the project, you are just running the last version.
A simple way around that is to change one character of code, change it back, and then run your project forcing Eclipse to recompile and upload the new project with the new resources to the device/emulator.
Do you use 9-patch images? If yes - they should be valid. Once I added an invalid 9-patch image and as a result my Eclipse failed to build the app while it had not informed me what was wrong, so I spent some long time figuring out what it could be.
Another idea - image file name should only consist of a-zA-Z_ chars. Yes, commonly used '-' (minus) char is not allowed.

Android Emulator Debugging, Code will not Update

I'm having a troubling problem testing some code for and Android app. My app has two parts, and activity where the user changes some settings, and a broadcast receiver that responds to SMS messages, both in the same package.
Here's the problem, I first implemented some simple code to test out the broadcast receiver and the activity, and both worked fine. But then as I tried to refine the code, I noticed the emulator wasn't picking up any of my changes. Event went so far as to uninstall the app from the emulator and try again, no luck. Then I added some extra Toast popups to my receiver, nothing, still running the old code. I know its running the old code because its sending out an SMS using a string constant that is no longer in the current code, so it should be impossible that it respond with that value.
Here's the kicker that has me confused. For fun I made a change to my activity. Ran the project from Eclipse and that change showed up! Tried to test the receiver code again, runs the old code that doesn't even exist anymore!!
How in the world can half the package update, and the other half not?
Can anyone help me out 'cause I'm about ready to lose my mind.
I had a similar problem. Changes made to classes imported from another project didn't get picked up by eclipse, but those made to classes in the current android project were.
Making a change to the current android project (inserting a blank line and deleting it) seemed to make eclipse pick up all the changes made and upload the app to the emulator.
I had this problem too, Now I found a working solution. Just follow these steps:
Run your project normally.
When emulator started, run your project again (DO NOT close the first emulator)
Then the updated application will be uploaded into emulator
I can't really be sure what happened but creating an new emulator image appeared to solve the issue.
I don't know why it happens but it's a problem I have all the time.
What I typically do is
Close the emulator
Close Eclipse
Reopen Eclipse
Clean the projects (in Eclipse, select Project -> Clean... -> Clean all projects)
Rerun the emulator
Annoying as hell but seems to work for me.
I'm having this problem too. It mostly happens when errors are entered into the code. The strange thing is if I go back to the original code, Eclipse doesn't revert to the original code. One thing that seems to help is to temporary delete the contents of a file, save, and rebuild, and then enter the contents back into the file, save, and rebuild.
How is one supposed to debug in such an environment?

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