Showing posts with label eclipse. Show all posts
Showing posts with label eclipse. Show all posts

26 April 2012

10 April 2012

Quick Tip: git cloning

A user-friendly way of cloning a git repo is through the eGit plug-in in Eclipse. But sometimes, especially on Windows machines, Eclipse has trouble cleaning up after itself after completing a clone operation. The best workaround for this is to clone the repo from git bash and then import the repo in Eclipse.
default@ZDOMINGUEZ-T420 ~
$ git clone git@github.com:<your git repo> <local folder to check out to>
When git finishes cloning your repo, import it to Eclipse.
Browse to the folder you checked out to, click OK, and the newly-cloned repo should now appear on the Git Repositories view.

07 September 2011

Where's my R.java?

This afternoon, I tried importing an existing project into Eclipse. Doing a Project > Clean usually clears up the R.java not found errors, but this time it didn't work. I tried re-importing the project, copy-and-pasting it into a new workspace, restarting Eclipse, but the error is still there.

Just a quick note to self: If there is an error in the layout files, resolve that first then Clean.

I find it weird that no more specific error message is presented. Oh well.

11 July 2011

ADT 12: Not so shiny after all


For all the shininess that ADT 12 promised, it seems that it also broke one major feature of DDMS: Launching emulators.

After updating to ADT 12, I kept on seeing that error when launching an emulator instance. Restarting Eclipse doesn't help any.

Anyway, the apparent cause of this error is that ADT 12 has some problems with the SDK location having spaces. If you have already forgotten, it's in Window > Preferences > Android.

To work around this bug, it is either you move your SDK to a folder in a path without spaces; or, modify the existing path to either of the following:
  • If your SDK is in Program Files: C:/PROGRA~1/<path_to_sdk>
  • If your SDK is in Program Files(x86): C:/PROGRA~2/<path_to_sdk>
Edit (20110711 1943): A bug has already been filed for this issue. Star to be notified of updates.

10 December 2010

Quick tip: Quick Formatting of Android XML Files

One of the most useful tools in Android's Eclipse plug-in is the Layout Editor. It is easy to experiment with layouts using the drag-and-drop enabled editor without having to worry about the correct syntax or if you are using the correct attribute name.

After creating your layout this way, however, you can end up with a messy XML file. I say "messy" in the sense that elements can run on in one veeeeeeeeeeeery long line, and if you are about to edit the XML file manually, this can be a nightmare.

I used to format the XML file by hand, putting in line breaks and correcting indentation. But one edit using the graphical layout editor and it's messed up again. And then I had a light bulb moment. Eclipse allows auto-formatting of code, but what about XML files? AHA!

It turns out that auto-formatting works for XML files too! Simply select all the contents of the XML file (CTRL-A) and then press the ultra magical shortcut CTRL-I and your XML file is clean and orderly as can be! YAY!

What happened to my layout editor?

There you are, happily creating your layout files in the Eclipse plug-in's layout editor. Dragging and dropping is a breeze. But then one day, you open a layout XML file and boom! No UI! All you see is the XML tree with all the nodes and attributes. What happened?

This happened to me and I was in a panic for a few seconds. Why do things like these have to happen to me? I tried opening a layout file from another project in the same workspace, and it has the UI! What happened?

It probably has something to do with the interpreter you used to open the XML file, a voice in my head said. So I tried right-clicking on the XML file, and lo and behold, I found it. I may have accidentally clicked on some file in one of my mad-clicking moments and changed the setting.

So anyway, to bring back the Layout UI Editor, right click on an XML file > Choose Open With > Android Layout Editor.

I would say that everything is handy dandy, but apparently, the engineers at Google decided that we developers need a little less help and removed the very useful up and down arrow keys in the Outline View when editing XML layouts. Why do they hurt us like this?

I WANT MY UP/DOWN KEYS BACK!

11 November 2010

What grammar?

My OC side was alarmed when suddenly, my Problems view in Eclipse was filled with warnings on my XML files. Each of my XML files had a warning with it, and that little yellow exclamation mark on the side:
No grammar constraints (DTD or XML schema) detected for the document

So how do you get rid of it? Go to Window > Preferences > XML > XML Files > Validation then set Indicate when no grammar is specified to Ignore. Click on Apply.

Clean up your project (Project > Clean).

If the problem doesn't go away, you may need to re-validate the XML files. Right click on the file then choose Validate from the popup menu. You can also right click on the folder (such as your res folder) and validate from there.

10 September 2010

Importing existing Android projects to Eclipse

When trying to import an existing Android project to Eclipse, I always encounter the error: The method XXXXX must override a superclass method.

At first I was confused. I think this is a Java 1.5 thing, but I am running Java 1.6, and a quick check with my workspace settings show that this is indeed the case. So why the errors?

I searched the intarwebz, and I found out that I am not the only one encountering this! Now I do not want to comment out all the @Override annotations, since it is tedious and would dirty up my code.

Turns out that this is a weird Eclipse behaviour that you can correct with a few simple clicks.


Go to Window > Preferences > Java > Compiler. It should show the compiler compliance level to be 1.6, but the errors are still there. What the frak, Eclipse? Just to be sure, select 1.6 in the dropdown options. This worked for me, but if it doesn't work for you, try the next step.

Click the Configure Project Settings link. It should show a list of the projects in your workspace. Choose your Android project, click OK. Tick the Enable project specific settings box, then choose 1.6 as the compiler compliance level. That should work. :)