Android Development Tips and Troubleshooting:

Overview: Android programming is surprisingly easy and relatively unproblematic, especially when you consider the enormous diversity of platforms to serve. Still, there are some weird little quirks, and plenty of tricks that you have to learn along the way to streamline your development process.

To help you get going, here are a few of the questions...and their answers...that I've come up with in my experience.

Q: What development tools should I use for Andoid programming?
A: There are tons of development tools and IDE options; everyone has their favorite. I looked at a few and can definitely recommend using Eclipse with the Android ADT plugin. This is clearly the most common IDE setup for Android programmers and seems to have excellent support. It will let you get an effective Android project going in about two hours of installation and exploration.

Q: Which Android version(s) should I use?
A: This is a tricky one, because not all Android versions run on all devices. Check out the Wikipedia entry on Android version history to see what specific versions there are. For a professional developer, the answer to this question would ideally be "whatever version runs on your specific targeted device(s)". If you want to develop generic "run anywhere" apps, you'll need to pick a lowest common denominator. In our case, this lowest common denominator is Android "Gingerbread", meaning API level 10. This may not run on all (i.e. even the oldest) devices, but should work well on pretty much anything since about 2010.

Q: So what devices are we using in this class?
A: As mentioned in class, you are welcome to use your own handset for testing. To turn in your project, however, you will be loading it onto a Google Nexus One phone. This was Google's flagship Android phone for many years, and has an excellent display and other hardware. See the Google entry on this phone to learn more about the hardware configuration and capabilities.

Q: I get a frustrating error every time I try to compile-run: "Application requires API version 15. Device API version is 10 (Android 2.3.3)"
A: To understand this, you have to understand more about Android API levels. Here is the nutshell version: Android versions are classified by API level. As we said above, API level 10 is a good common denominator if you don't need the latest and fanciest. Part of what you can declare for any Android project is the "Minimum SDK level", which states the minimum SDK your application will run on; this is stored in XML in your android manifest file. You are getting this error because your project's Min-Sdk level is set higher than any device or emulator you have connected...so it thinks it can't run and aborts. To fix it, you edit your manifest file and change the Min-SDK to something lower (like 10). Here is more detailed information on the whole "API level" concept and how it affects developers.

Q: I keep getting this weird warning: This application, or a library it uses, is using NSQuickDrawView, which has been deprecated.
A: This seems to be an anomaly when developing on the MacOS platform, and launching in the emulator. Just ignore it, it means nothing. Strangely, you generally don't get this warning at all if you've started and are running your emulator BEFORE you try to run.

Q: I get a variety of weird errors related to "sensors not found" or "audio input/output failed". Should I worry?
A: Again, these are meaningless errors. All of them just mean that the emulator wasn't able to hook up to hardware/sensors that it was expecting....hardly a surprise, seeing as you have no accellerometer on your development machine! These should go away when you are launching onto an actual device...unless the device you're launching to doesn't have the hardware it's looking for.

Q: So how should I use the emulator, versus using actual hardware?
A: Ultimately, of course, you'll need to submit your prototype for grading on the hardware device. So you'll want to use that for final testing. But the emulator can get you a long way. Some tips: First, create and "Abstract virtual device" (AVD) that matches your target device: in this case, it means creating an AVD based on Google's level 10 API. Second, start your emulator running before you compile/run in eclipse....and KEEP IT RUNNING as you develop!! Do NOT shut down the emulator after every test run! The emulator takes FOREVER to start up...we're talking like five minutes in some cases. So start it once when you start your session. Then just keep loading updated apk's to it as you edit/run your app. That way you have a nice fast dev cycle.

Q: Do you have some tips on project preferences to set for Android development?
A: Yes. First, make sure you create your project aimed at the right API level. This makes sure that the "min-SDK" attribute is set correctly from the get-go. The other thing I like to do is to edit the project preferences --> Run/Debug settings --> and then edit the Launch config for your app. Under the "target" tab, it wants to automatically select the target. In theory, this is nice: it selects a physical device if connected...or the latest possible AVD if not. In practice, you probably want to set this to "manual". That way you can tell it, each time you launch it, which physical device or emulator you want to install/launch it to. Makes it easy to use both several emulators...with or without a physical device attached. It's all about control!

Q: next question?
A: next answer

Q: next question
A: next answer