Android Ideas

App Developers: Be careful with Proguard and Eclipse “User Libraries”

One convenient feature of the Eclipse IDE is that it lets you create "user libraries" to hold jars as well as source, javadocs, etc. This is useful even if you only have one jar in there, since you can update that jar and all the projects that use it instantly use the new jar.

While this is convenient, I've spent way too long fighting with Proguard while it says things like

can't find referenced class

and suggests

You may need to specify additional library jars (using '-libraryjars'), or perhaps the '-dontskipnonpubliclibraryclasses' option.

when I know good and well the jars are there.

Upon Googling the problem I found many solutions that involve using "-keep public class" and "-libraryjars" along with other such things. The right combination of these allow Proguard to complete and produce the APK, but your app will ultimately fail upon run:

Caused by: java.lang.ClassNotFoundException: in loader dalvik.system.PathClassLoader

Well, if you're having this problem give this a try:

The Solution

Do you have any "user libraries" in your project? Well get rid of those and replace them with the actual jars, then be amazed that such a silly thing could have been your problem all along. Of course this isn't optimal since if you're using user libraries you probably want them in there. There might be a way to keep them and still use Proguard, but I'm not sure. Either way, I hope I've saved you some time. Happy coding!


TaskBomb Released!

TaskBomb is my task-scheduling / automation app for Android.  It can theoretically do anything your Android device can do. It gets a little trickier in practice, but it's being rapidly improved. There's already enough functionality to build one great alarm clock. My personal alarm includes waking up to streaming radio (or a backup if that fails), having the volume gently increase, and switching to a playlist of nostalgic songs to get me out of bed if I still haven't after 10 minutes. [1]

With the announcement of Android@Home and the Android Open Accessory API this app comes just at the right time. TaskBomb's unique scheduling system is well-suited for automating things around the house. Imagine a space heater that begins making your bedroom toasty and warm 15 minutes before you wake up to your favorite internet radio station. Meanwhile your curtains slowly open to let the sun fall on your face. You hit the snooze button on your Android phone to delay the music for another 9 minutes while you lay back in the sun like a happy cat. The possibilities are endless.

Learn more about TaskBomb or get it from the Android Market

1. The nostalgic songs thing works by the way. It gets my heart racing and before I know it I'm wide awake. I try to only use it when I really need it, like the Philadelphia Flyers and Kate Smith. If you try this method, here's a song you might want to add to your playlist.


Apps vs. Applications: A Paradigm Shift

Apps and applications are in many ways similar, but have different underlying paradigms.

Applications tend to be more complex and feature rich. Jamie Zawinski once remarked that "every program attempts to expand until it can read e-mail." Applications often turn into Swiss Army knives with each providing several, often overlapping pieces of functionality.

Apps by comparison are more like silverware, each with a specific purpose or closely related set of purposes. You'll occasionally find a spork thrown in there, but this tends to be the exception and not the rule. In this sense apps are truer to the old UNIX philosophy:

Write programs that do one thing and do it well. Write programs to work together.

Until mobile apps arrived on the scene, it seemed that we were moving increasingly further away from this ideal. Microsoft Word for instance, an application used by hundreds of millions, ships with more features than most of them would ever want to learn. This complexity comes at a cost. At a certain point adding more features actually makes the average user take advantage of less features. Many people who would potentially benefit from some of the advanced formatting tools in MS Word are hesitant to learn them since they're among hundreds of other unfamiliar features.

Apps are a welcome change from these beasts, both for users and developers. Smaller, cohesive chunks of software are both easier to learn and write. It basically forces you into using good design principles, or at least makes it hard to screw up too badly. It allows for smaller, more efficient teams. It makes the product more maintainable and makes bugs easier to find.

Apps aren't merely applications for small devices, they represent an exciting shift in the software world. In some ways it's a shift back to the UNIX philosophy of "one thing well" that's been around for over 40 years. It's not a new concept by any means, what's new is how mainstream and widespread it's finally becoming.