Showing posts with label development. Show all posts
Showing posts with label development. Show all posts

Wednesday, March 2, 2011

Tip: Speeding Up Your Android Emulator Launch

The latest version of the Android emulator comes with a feature called "snapshots." It needs to be enabled as a feature of each AVD. Luckily, this version also includes the ability to edit existing AVDs.

First, enable the feature:

Enabling Snapshots

Second, when launching the AVD, choose to load from the snapshot and save the snapshot. When a snapshot isn't found, the AVD boots up from scratch. As we all know, this takes quite a long time even on very fast machines.

Enable Snapshot options

Now, when you exit, the system will store off a snapshot of the state of the AVD. This takes a little while, depending on how much RAM is assigned to the AVD. After saving the state once, the AVD will now launch very quickly - usually in just a couple of seconds.

However, the exit is no longer super speedy and often triggers "Not Responding" type messages. If you always want to return to exactly where you left off, this is how it will work. Overall, the behavior is much faster. However, if you want it to come up clean each time, just make sure the first time you boot it's clean, then exit to save the snapshot. Now, when you launch the AVD, only check load from snapshot, but make sure save to snapshot is unchecked.

Don't save over old snapshot

Now, the system will just load the AVD from the one snapshot you created and not save the state each time you exit. This means super speedy launches into a cleanly booted emulator as well as super speedy exits since the snapshot doesn't have to be saved each time.

You'll start to feel like you don't need to keep the emulators running all the time. You also won't necessarily go looking for a phone each time just to save the emulator boot-up time. (You'll still go after the phone or tablet when debugging for performance or with code bases that are otherwise slow on the emulator or other such reasons.)

How much difference does it actually make? Here are some test results running on a 6 core 3 GHz desktop with 8GB of RAM and a relatively speedy SSD:

  • Cold launch of Android 3.0 emulator to a usable state: 4 minutes 35 seconds
  • Snapshop launch of same Android 3.0 AVD: 8 seconds

That cuts the emulator launch time by 97%. Put another way, the cold launch takes 34 times longer. Taking these steps is well worth the minimal additional effort.


Happy Android Coding!

Friday, January 28, 2011

Discounted Android Books for Purchase

Android Wireless Application Development (2nd Edition) (Developer's Library)Don't think you'll win a free (signed) copy of Sam's Teach Yourself Android Application Development in 24 Hours from Mobiletuts+? Already have the Sam's book or the first edition of Android Wireless Application Development, but haven't gotten around to buying the second edition?

Well, InformIT is offering up a discount for the second edition of Android Wireless Application Development -- 40% off with the coupon code ANDROID until March 15, 2011. That's a little better than the regular Amazon price. :)

Wednesday, January 26, 2011

Honeycomb Preview Now Available

Earlier today, I was just telling someone how we lesser mortals almost never get SDKs much in advance of hardware anymore. Well, we just got one: the Honeycomb SDK preview.

And, besides the preview, the SDK tools and plugins have been updated. Sounds like good stuff. Now to go digest it all for an afternoon snack.

Even if you can't use the new SDK, don't forget to update your tools.

After you've digested it, let us know your favorite new features!

Thursday, October 14, 2010

Reader Feedback: Manifest Permissions Editor

[UPDATE: 13 Feb, 2011: This problem now longer exists in ADT 9.0.0 (the version right after 0.9.9).]

The Android Manifest file editor within Eclipse provides a number of useful editing tabs to wrangle the complexities of this file. One such tab is the Permissions tab. Use the Permissions tab to manage the permissions that your application uses and grants to others.

If you've been working with Android for a while, then you may be familiar with the permissions listed in the drop-down when you register a new permission using the uses-permission tag. We refer to this feature in both our books; specifically in Sam's Teach Yourself Android Application Development in 24 Hours, Hour 5, "Configuring the Android Manifest File."

Unfortunately, a recent update to the Android Development Tools plugin removed this drop-down. We're not sure if it's a bug or not yet, but the drop-down disappeared in the software update between ADT 0.9.8 or ADT 0.9.9.

What used to look like:

Permissions tab from ADT 0.9.7 showing the drop-down list of values
Now looks like:
Permissions tab from ADT 0.9.9, with the corresponding Browse... dialog
When you press the Browse... button, the dialog comes up.

The field provided still works for typing in permissions values by hand, instead of selecting them from a list. The alternate method, editing the XML file directly from the last tab, hasn't changed at all.

So where is one to get these values to type in yourself? On page 90 and 91 of the SAMS book, we've listed a number of the most common permission values. However, the best place to get the appropriate values for your applications is from the Android SDK documentation. Permissions are defined in the documentation for the android.Manifest.permission class. Also conveniently listed with these values is a short description of what they enable the application to do. Before including a permission within your application, always check the documentation to determine if that is the most appropriate one to use.

Friday, September 17, 2010

Building an Android Application: Book Excerpt

Sometimes publishers allow sites to publish entire chapters of books. ComputerWorld recently published a complete chapter from Sam's Teach Yourself Android Application Development in 24 Hours. We think this is a particularly good excerpt, too, as it has broad topic coverage.

This excerpt, from Hour 3, covers topics from application design to resources to Android Activities. And then it goes on, and covering Activity lifecycle and even Intents and various things you can do with them as a developer. You even get information about debug logging. It's not just a preview of Hour 3, it's nearly the whole chapter.

Check it out at ComputerWorld!

Tuesday, September 14, 2010

¡Hola! Writing Android Apps for Different Languages and Locales

Find out how this
screen is localized!
It's easy to write Android applications in multiple languages and locales. By clever storage of localized resources in specially named project directories, most of the work in application internationalization is done for the developer. Whether you want to write an application that supports English and French, or Austrian German vs. Swiss German, you can learn how in our tutorial on Mobiletuts+.

Resources need not just be strings, either. Learn how to localize and internationalize your strings, colors, images, and more in Android SDK: Building a Localized Phrasebook.

Thursday, September 9, 2010

Reader Feedback: Missing Code! Creating Android Widgets

Not all of the feedback we get is from our books. We write articles for numerous sites around the net and in print form. On most of these systems, we don't have a good way of updating or changing the article once it's posted. Recently, we came across an issue where a series of articles lost their download links for the source code. This series was written back in October of 2009 and discussed creating widgets for Android on the then-new Android 1.5.

We have moved all of the widget tutorial code to Google Code hosting so it should stick around for longer.  The tutorials are still available from developer.com:

Tuesday, September 7, 2010

Android 2.2 Spreading Wide

We visited the sculptures
after Google IO 2010
Android 2.2 has been getting a lot of news lately. Instead of just being available on the Nexus One, it's now available on many devices, and even shipping on news ones like the Droid 2. A while back we wrote a few articles about Android 2.2 (aka FroYo!). These are relatively high level overviews, but for some they can serve as a reminder of some of the features that we were excited about yet forgot all about because it's been so long since the announcement.

Recall ten of the most anticipated items us developers were looking for in Top 10 Android 2.2 Features Developers Can't Wait to Use. Anticipated, but have they lived up to the hype? You tell us. Interestingly, Cloud to Device Messaging is still not widely available. And, although it's a user feature, we're definitely seeing that not all carriers are taking the Tethering option as it was developed. The Nexus One could very well be alone in it's implementation.

We took a look at past desserts of Android and compared them to the latest, FroYo (mmm, Frozen Yogurt!), in Android 2.2 and Its Previous Versions: A Sweet Developer Review. Although most of the full API level updates have been fairly minor (especially, for instance, API Level 6 to 7), when you look all the way back to API Level 1, the changes have been substantial. Not only have the APIs changed, but the tools have vastly improved. They started out being surprisingly good for a very young platform. Now they're better than even more mature platforms.

Lastly, we wrote an overview of Android 2.2 for users and developers alike, printed in Linux User & Developer magazine, a UK publication. Hey, Android is available worldwide, mates!  This one covers many of the same topics, naturally. (What, did you expect Android 2.2 to change?)

With Android FroYo old news now, what are you most looking forward to in Gingerbread, the next expected release of the SDK (presumably API Level 9)?

Monday, August 16, 2010

Creating Useful AVDs

Various Android Virtual Devices
Many new Android developers just use a basic, default Android Virtual Device (AVD) for development purposes. This is fine when you're just getting started, but when you get serious about designing and developing apps for specific devices, you'll want to give some thought to configuring AVDs to match devices your users actually own.

In some cases, you can just switch to testing on real hardware instead of the emulator. If you have a lot of devices for your team, you can probably just switch to using devices. However, if you can't afford devices for everyone on the development and test team or can't get your hands on some unusual devices with unique hardware characteristics, you can create AVDs to simulate these. Head over to Mobiletuts+ and read our tutorial about creating AVDs that come as close as possible to simulating the following devices:
  • HTC Evo 4G
  • Google/HTC Nexus One
  • Motorola Droid
  • T-Mobile/HTC G1
  • Archos 5 Internet Tablet

Friday, December 11, 2009

Latest Book Review: Android Wireless Application Development

Thought we'd share with you some comments from our readers. Recently, our youngest and most loyal fan kicked off his future career in mobile software development by "reviewing" our recent software development book, Android Wireless Application Development.

His verdict: Tasty!


"I can also create user interface components at runtime programmatically? Fascinating. Read on!"


"Need my diaper changed. Is there an app for that?"



"I especially enjoyed the bunny pictures!"

"Forget baby sign language, I'm learning Java so I can write killer apps for the Droid phone! I can use royalties I rake in from the Android Market to pay for college... in 18 years."

Sunday, December 6, 2009

Consumer Confusion or Funny Feature?

In testing one of our apps on the Archos 5 Internet Tablet, I ran across something I found to be funny. See that screen shot? The one that looks like the emulator when the camera application is launched?

Yeah, that's on the Archos device.

I find it funny because I know exactly where that came from. But consumers? They might get confused by this. Ideally, the camera Intent would do something useful to inform the user:
  • Provide a warning message that the device doesn't have a camera
  • Go directly to the gallery picker instead
Or is this the right behavior so developers can just be lazy and not worry about there being a camera on all devices? And that is the final problem: the device behaves as if it has a camera when it doesn't. It might be convenient for running apps that don't know about the device features, but it actually makes it harder for well written apps.

(P.S. I'm not trying to pick on the Archos device, specifically. It's just the only Android device I have that doesn't have a camera.)

Friday, December 4, 2009

Quick Tip: Eclipse, Source Control, and default.properties


Here's a quick tip for you:

When using Eclipse project properties to change the Project Build Target, make sure the default.properties file is writeable. This may mean checking it out from source control before editing the properties. In our configuration, the Perforce file is not writable and changing the Project Build Target settings with Eclipse does not check out the default.properties file from source control. So, I have to first check it out, then modify the Eclipse settings.

Although default.properties is automatically generated by the Android Tools, the catch is it must also be checked in source control. Usually, this does not trigger an error, either. Instead, the default.properties file will just be out of sync with the settings and possible create strange behavior.

Friday, May 15, 2009

Android Development Tip: Managing AVDs with the Eclipse Android Development Tools Plug-In

I've updated my Eclipse development environment a number of times in the past few weeks, what with the Android 1.5 preview, then the release version. I checked for updates this week and noticed yet another version of the ADT Eclipse plugin was available. One interesting new feature added in the latest version is an Android Virtual Device (AVD) manager, accessible from within Eclipse.

All emulator instances using the Android 1.5 SDK require an AVD configuration. Sure, you can use the android command line interface to create and manage AVDs, but if you just want to create a simple AVD quickly, you can now use the little wizard provided with the ADT plugin. The AVD manager button is added to your Eclipse toolbar. It looks like a little black cell phone.



Simply click it and the AVD manager will launch, listing all AVDs on your system. You can Add and Delete AVDs, as well as Refresh the AVD listing.


When creating a new AVD, you can set the following information:
  • The AVD friendly name
  • The Target Android system
  • The Skin
  • Whether or not to create an SD Card Image

  • You cannot create custom hardware profiles. That, you still need to use the android command line tool for.

Wednesday, April 22, 2009

Android 1.5: Going Live Within The Next Few Weeks

image
The much-awaited Android 1.5 SDK update is coming soon to a development environment near you. This update is based on the Cupcake branch of the Android source project and features substantial improvements and additions to the Android APIs, as well as developer tool suite updates and some much-needed UI polish and performance improvements to the overall Android user experience.

You can find a short list of highlights coming in Android 1.5 as part of the Android Developer SDK 1.5 preview on the Android Developer website as well as download the pre-release ("preview") version of Android SDK 1.5 and give it a spin.

You may also find the Cupcake branch roadmap useful.

The SDK 1.5 is expected to be released within the next few weeks. An over-the-air update will likely be sent to Android phones in the field soon thereafter.

What are you looking forward to in this release? We're looking forward to being able to create home screen widgets.