Home > Articles > Mobile Application Development & Programming

Using the Android Emulator and Developer Tools to Build Bullet-Proof Android Applications, Part 1

What can you do to separate your Android app from all the others and get noticed? In this article, Jesse Smith explains how using the Android emulator for effective testing can improve ratings (and therefore success) in the market. Part 1 of this two-part series covers performance and the emulator configuration options.
Like this article? We recommend

Like this article? We recommend

I have been programming Android applications for only about six months, not a long time, but long enough to know what is important and what isn't with regard to building successful Android applications. As it is now, only about 1% of the Android apps on the market actually make money. For these apps, it is often a combination of luck and robust applications that do not produce many errors.

With so many apps in the market now, many perform similar functions. For example, there are dozens and dozens of apps that read text messages out loud as they come in. If your app was early in the market, there was a chance for some success as there were many fewer apps to compete with.

Nowadays, it comes down to winning a major app contest to get noticed or picked by an Editor of the market to gain exposure. The contests were a big deal 3-4 years ago, but now you'd be hard-pressed to find one (and if you do, it isn't anything major). So not having contests as an option leaves the Editor picks for apps and word of mouth.

Sure, you can have your app promoted on blogs, but this only goes so far for so long. It takes tens of thousands of users to take notice of your app, and many of these sites simply do not have that traffic, though they claim to.

So what can you do to separate your app from all the others and get noticed, say by an Editor, high-profile blogs such as Techcrunch, or word of mouth? The only answer I have found thus far is effective testing and uniqueness of your application to produce any kind of consistent success on the market.

In this article, I share with you what I have learned about using the Android emulator for effective testing and to produce low error-prone apps, which improve ratings (and therefore success) on the market.

This article, Part 1 of a two-part series, covers performance and the emulator configuration options.

The next article, Part 2, will cover application testing, command-line options and more. By the time you're done with both parts, you should be well adept in using the emulator effectively.

Android Emulator Performance

One of the biggest complaints I often see on development help sites such as Stack-Overflow is that the emulator takes much too long to load—several minutes in fact. I found this to be true, even when I used a 2.2 GHz AMD processor. Sometimes it would not load at all and just hang with the Android logo flashing on the emulator screen.

Now I use an Intel i7 series processor, and the emulator loads nearly instantly with little or no wait time. A big difference. It could be because the i7 is a multi-core processor, more than dual-core.

I highly recommend the i7 processor for heavy-development. Furthermore, to increase performance, I use a USB drive as a ReadyBoost cache. You can learn more about ReadyBoost at http://en.wikipedia.org/wiki/ReadyBoost.

One of the key reasons why the emulator is painfully slow is because the Android OS uses the Dalvik Virtual Machine. Typically Java code, when compiled, is converted to machine bytecode and then executed by an application's virtual machine.

With the Android OS, Java is converted to bytecode and then to Dalvik code that is then executed by the Dalvik VM. The Dalvik VM has lower memory requirements than your traditional Java VM, thus optimizing memory usage. The emulator, in order to be a true emulation of an actual Android device (i.e., phone or tablet), must use the Dalvik VM.

To improve startup performance of the emulator, you can also you the Snapshot option. It is one of the launch options you can turn on when editing the details of an emulator using the Android Virtual Device Manager (AVDM).

In Eclipse, this manager can be accessed from your Windows menu. Taking a snapshot means that the emulator will launch to that saved state, thus launching much faster than usual.

You first have to start the emulator normally, and then when closing, a snapshot will be saved. The next time you start, it will use this saved state to launch the emulator.

Configuring the Emulator

To configure the emulator, you access the AVDM and either create a new emulator or edit an existing one. The following options are available for configuration with the Android SDK version supporting API 17. Each version of the SDK supporting the various APIs has a different flavor of the emulator, but the majority of the options remain the same.

Following are the options that are available for configuration:

Device

From this this drop-menu, you can select a predefined device for testing. A device is a configuration that emulates a particular device model, such as the Nexus One. While there are several predefined devices that come with the SDK, you also have the ability to create your own simulation devices.

This can be done by clicking the Device Definitions tab from the AVDM. From this tab's panel, you can click the New Device button to create a new device. Below are the options that are available for configuration:

  • Name: The name of the device, for example "Evo4G"
  • Screen Size: The screen size in inches (i.e., 3.5")
  • Resolution: The screen resolution, for example 960 x 640
  • Cameras: Select a Front or Rear camera (or both)
  • Input: Keyboard, or either No Nav, Dpad, or Trackball (No Nav is most common for phones).
  • RAM: Amount of memory the device has (i.e., 768MB)
  • Size: Normal, Small, Large, X-Large. The size often depends on the resolution: the higher the resolution, the larger the screen size. Normal screens are least 470x320.
  • Screen Ratio: Long or Not Long. Long indicates that the device, when in portrait or landscape mode, has a significantly taller or wider aspect ratio than the baseline screen configuration. Not Long indicates the opposite; the aspect ratio is close to the baseline configuration.
  • Density: The quantity of pixels within a physical area of the screen, usually referred to as DPI (dots per inch). There are different density ranges that belong to various categories, including mdpi, hdpi, ldpi, and so on. Mdpi represents a medium range, while ldpi is for low ranges, and hdpi is for high ranges.
  • Buttons: Hardware or Software. The most common setting is Software; Hardware indicates that the device has an external hardware keyboard.
  • Device States: Portrait or Landscape. It is common to include both of these modes. You can also specify these states for use with Keyboard if you enabled Keyboard as the input option.

Target

The target API. Each Android device version is associated with a corresponding API. For example, Android 2.2 is associated with API 8. When specifying this target, it just means the maximum API that the device should operate for. If you specify a lower API (for example, API 8 and a 4.1 device runs your app), it will not work correctly for any new features included beyond API 8. It is a best practice to target as high as possible.

CPU

The target CPU of the device. ARM is for x86 processors (which most PCs use) or the MIPs CPU architecture, which is uncommon. MIPs is a higher-performance processor because it uses Registers to perform operations on. You could likely say it has the performance of a low-level language like Assembly.

You'll probably notice there is an option for Intel Hardware Accelerated Execution Manager (HAXM). HAXM is virtualization technology that is used to speed up the emulator. I personally use this and can tell you it does make quite a difference for emulator performance. You can view the requirements and instructions for installing HAXM at http://software.intel.com/en-us/articles/installation-instructions-for-intel-hardware-accelerated-execution-manager-microsoft.

Keyboard

Selecting this option is useful for devices that have an external hardware keyboard.

Skin

Display Skin with Hardware Controls. I personally always choose Display Skin with Hardware Controls because by doing this, you can use your computer keyboard to type in text for apps running on the emulator.

For example, if I want to send an SMS message using the emulator, the message can be typed using my keyboard, which is much faster than using the software keyboard of the emulator.

Also, by selecting the display skin option, you can quickly navigate the emulator using the hardware buttons like the Home or Back buttons. If you do not choose either option, you will be forced to use the emulator's software keyboard.

Front Camera

Some devices have a front camera, like the HTC Evo 4G, for example. If your device definition included a front camera, you will be able to enable this option; otherwise, it will be grayed-out. If you have a webcam, the camera will use the webcam to project the video onto the emulator screen.

Back Camera

Like the front camera, you can choose to enable a rear camera (which most Android phone devices have). By doing so, you can use your webcam to project the video onto the emulator. If using both a front and back camera, you can simulate each one by using two webcams.

Memory Options

Memory Size and VM Heap. Memory size is the amount of memory the device should have specified in MB. Many phones today now have at least 1 GB of memory. 1 GB is equal to 1024 MB.

The VM Heap specifies the heap size of the virtual machine in MB. The heap size should increase as the RAM specified gets larger. The heap is used to store instance variables of instantiated class objects. Garbage collection is used by the VM to free the heap space.

Internal Storage

This option will set the amount of internal storage space the device will have. Phones today often have several gigs worth of native storage space. The need for external storage is becoming less needed.

SD Card

This represents an external storage device. It is useful if you have used up your limited native device storage. Usually a large amount of images, etc., are good candidates for storing on an external storage device.

Emulation Options

Snapshot

This option was already detailed in the Performance section of this article. It essentially allows your emulator to boot up faster.

Host GPU

This option is also performance related. It allows the emulator to use the graphics processing unit (GPU) of the host machine the emulator is running on. This results in a faster emulator. This option is only available in the most recent version of the SDK at this time.

Conclusion

This concludes part 1 of this article series. You should be more familiar with the core emulator options which are important for effective testing of your application using the emulator. In the next article, I will introduce testing scenarios, developer options, using the command line and more.

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020