Tuesday, May 31, 2011

Important Android change for IntelliJ IDEA 10.5 users

The ever-productive guys over at JetBrains have released the new 10.5 version of IDEA, their flagship Java IDE.  IDEA has been my weapon of choice for over a decade now, and I still just love it over the competition - of course I know there are cases to be made for other environments too, and certainly to each their own.  IDEA just feels right for me.

Check out this blog entry if you use IDEA as an Android development environment and upgrade to 10.5.  They've changed the way Android SDKs are modeled, so the Android SDK is the project SDK in the new world, as opposed to having the Android SDK "bolted on" to a module.  This ends up being much nicer, but I found that the supposed "transparent / automatic" upgrade did not work for my projects.  Luckily, the process of setting up the SDK takes about 20 seconds - you just need to stop looking for the setting in the old location. :)

Hope everyone (in the US anyway) had a terrific holiday weekend!

Saturday, May 21, 2011

Handy Android Debugging Tip!

Well, completely ignoring the 2+ year hiatus since I last wrote on this blog (hi all you folks who are still subscribed!), wanted to note down a quick tip for Android developers.  I've been working on a new project lately which has me working in Rails and Android, and I'm having a blast with both.

When building your awesome Android app, you'll often use the logcat output to debug stuff.  Example:

log.d(Constants.REMOVE, "Last updated date is " + lastUpdated.toString());

So, here's the cheesy-simple tip.  Sometimes you want to get the context of exactly how you got to the method in question when logging something like this.  In the case above, this is in the midst of deserializing some JSON and we could get to this code down a variety of paths.  So to get a stacktrace in your log output, just use the other form of the Log call (such as you might normally do within a catch block) with a freshly-minted Exception that you don't throw:

log.d(Constants.REMOVE, "Last updated date is " + lastUpdated.toString(), new Exception());

And voilĂ !  (by the way, I use the Constants.REMOVE tag for transient debug logging, so that I can do an easy sweep of my code to remove them before checkins)