Skip to content

Most visited

Recently visited

navigation

Device capability for billions

Reaching new users means supporting an increasing variety of Android platform versions and device specifications. To improve the user experience, optimize for common RAM configurations, and screen sizes and resolutions.

Support multiple screen sizes

Your app can provide a better user experience for billions of users if it supports screens of various sizes and resolutions. This section describes a few ways you can do this.

Use density-independent pixels (dp)

  • Defining layout dimensions with pixels doesn’t work well because different screens have different pixel densities, so the same number of pixels may correspond to different physical sizes on different devices.
  • To overcome this Android supports the density-independent pixel (dp), which corresponds to the physical size of a pixel at 160 dots per inch (mdpi density).
  • Defining layouts with dp ensures that the physical size of your user interface is consistent regardless of device. Visit the Android guide on Supporting Multiple Screens for best practices on using density-independent pixels.

Test text and graphics on ldpi and mdpi screen densities

  • Test to ensure that your text and graphics work well on low- and medium-density (ldpi and mdpi) screens because these are common densities, especially in lower-cost devices. Look out for text that may be unclear on lower-density screens, where fine details aren't visible.
  • Devices with lower-density screens tend to have lower hardware specifications. To ensure that your app performs well on these devices, consider reducing or eliminating heavy graphics processing loads, such as animations and transitions.
  • For more information about supporting different densities, see the Android training on Supporting Different Densities.

Test layouts on small and medium screen sizes

  • Validate that your layouts scale down by testing on smaller screens. As screen sizes shrink, be very selective about visible UI elements, because there is limited space for them.
  • The Material Design guidelines describe metrics and keylines to ensure that your layouts can scale across screen densities.
  • For more information about supporting different screen sizes, see the Android training on Supporting Different Screen Sizes.

Provide backward compatibility

Not all of your users may be using devices powered by the latest, greatest version of the Android platform. Here are some ways you can improve backward compatibility, helping make your app available to as many people as possible.

Set your targetSdkVersion and minSdkVersion appropriately

  • Apps should build and target a recent version of Android to ensure they offer the most current behavior across a broad range of devices; this still provides backward compatibility to older versions. Here are the best practices for targeting API levels appropriately:
    • targetSdkVersion should be the latest version of Android. Targeting the most recent version ensures that your app inherits newer runtime behaviors when running newer versions of Android. Be sure to test your app on newer Android versions when updating the targetSdkVersion as it can affect app behavior.
    • minSdkVersion sets the minimum supported Android version. Use Android 4.0 (API level 14: Ice Cream Sandwich) or Android 4.1 (API level 16: Jelly Bean)—these versions give maximum coverage for modern devices. Setting minSdkVersion also results in the Android build tools reporting incorrect use of new APIs that might not be available in older versions of the platform. By doing so, you are protected from inadvertently breaking backward compatibility.
  • Consult the Android dashboards, the Google Play Developer Console for your app, and industry research in your target markets to gauge which versions of Android to target, based on your target users.

Use the Android Support libraries

  • Ensure your app provides a consistent experience across OS versions by using the Android Support Library. This library provides backward-compatible versions of Android framework APIs as well as features that are only available through the library APIs such as AppCompatActivity and the Material Design Support Library.
  • Some of the highlights include:
  • For more information about the available support libraries, see the Support Libraries Features section of the Android Developer site.

Use Google Play services

  • Google Play services brings the best of Google APIs independent of Android platform version. Consider using features from Google Play services to offer the most streamlined Google experience on Android devices.
  • Google Play services also include useful APIs such as GcmNetworkManager, which provides much of Android 5.0’s JobScheduler API for older versions of Android.
  • Updates to Google Play services are distributed automatically by the Google Play Store, and new versions of the client library are delivered through the Android SDK Manager.

Use memory efficiently

Memory is an unsung hero of the user experience. Good memory management can make your app more stable and more performant; in some cases, its effective use may be the only thing making your app usable at all. Here are some ways you can help your app use memory wisely.

Reduce memory footprint on low-cost devices

  • Adjust your memory footprint dynamically to ensure compatibility across devices with different RAM configurations.
  • Methods such as isLowRamDevice() and getMemoryClass() help determine memory constraints at runtime. Based on this information, you can scale down your memory use. As an example, you can use lower resolution images on low memory devices.
  • For more information about managing your app’s memory, see the Android training on Managing Your App’s Memory.

Avoid long-running processes

  • Long-running processes stay resident in memory and can slow down the device. In most situations, your app should wake up for a given event, process data, and shut down. You should use Firebase Cloud Messaging (FCM) and GcmNetworkManager to avoid long running background services and reduce memory pressure on the user’s device.

Benchmark memory use

Android Studio provides memory benchmarking and profiling tools, enabling you to measure memory use at run time. Benchmarking your app’s memory footprint enables you to monitor memory use over multiple versions of the app. This can help catch unintentional memory footprint growth. Use the Memory Profiler tool to do the following:

  • Find out whether undesirable garbage collection (GC) event patterns might be causing performance problems.
  • Identify object types that get or stay allocated unexpectedly or unnecessarily.
  • Identify where in your code the problem might be.

For more information about benchmarking memory use, see View the Heap and Allocations with Memory Profiler.

This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Follow Google Developers on WeChat

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a short survey?
Help us improve the Android developer experience.
(Sep 2017 survey)