Wednesday, October 03, 2012

Android Libraries - When a Little Knowledge Kills

First post in a while but I thought this was worth dusting off the blog for.  So, I've been working on Android for nearly the last year and I've been enjoying applying my overall experience with Java and Eclipse to accelerate my team's productivity on the platform.  It's fun to know things.  But as the title of this post says sometimes it doesn't work out so well either.  Case in point, Android Libraries.  If you've worked with Java and Eclipse before I'm sure you're familiar with creating sub-projects for shared code.  It's easy, you create a jar project, add in the projects tab of the Classpath dialog of the project preferences. Easy-Peazzy-Lemon-Squeezy.  You can still do this with Android Library projects and things will compile and but you'll run into class loading issues when you run your code.  The solution is not use the standard Eclipse way of associating the library and instead go the Android tab of the project and add a reference to the Library project there.  That's easy too but if you're like me and think you know how to use Java and Eclipse it can take way too long to figure out.

TLDR: Don't use Eclipse standard methods for connecting libraries projects.  Use the Libraries list on the Android specific properties screen.
Post a Comment
The Out Campaign: Scarlet Letter of Atheism