Reduced data cost for billions

Data plans in some countries can cost upwards of 10% of a typical user's monthly income. This means that minimizing your app's download size and letting the user control how your app uses data can have a large, tangible benefit to many users. Minimizing download size also helps conserve space in internal storage, which is a scarce resource in some devices.

Here you can find some strategies to help optimize the amount of data your app uses, both over the network and in internal storage.

Reduce app size

Reducing app size is one of the fundamental ways you can help your user consume less data, in terms of both network data and internal storage. This section describes several approaches to reducing app size.

Reduce APK graphical asset size

  • Graphical assets are often the largest contributor to the size of the APK. Optimizing these can result in smaller downloads and thus faster installation times for users.
  • For graphical assets such as icons, use the Scalable Vector Graphics (SVG) format. SVG images are tiny in size compared to bitmap graphics and can be rendered at runtime to any resolution. The Android Support Library provides a backward-compatible implementation for vector resources to Android 2.1 (API level 7). Get started with vectors with this Medium post.
  • For non-vector images, such as photos, use WebP to reduce image load times and save network bandwidth. WebP is proven to result in smaller file sizes than its PNG and JPG counterparts, with at least the same image quality. Even at lossy settings, WebP can produce a nearly identical image to the original. Android has included lossy WebP support since Android 4.0 (API level 14: Ice Cream Sandwich) and support for lossless, transparent WebP since Android 4.2 (API level 17: Jelly Bean).
  • If you have many large images across multiple densities, consider using Multiple APK support to split your APK by density. This results in builds targeted for specific densities, meaning users with low-density devices won’t have to incur the penalty of downloading unused high-density assets.
  • For more information about reducing APK size, see Reduce APK Size and Shrink Your Code and Resources. In addition, you can find a detailed guide on reducing APK size in this series of Medium posts.

Reduce code size

  • Every library in your Android project is adding potentially unused code to the APK. Be particularly careful about using external libraries because not all libraries are designed for use in mobile apps. Ensure that the libraries your app is using are optimized for mobile use.
  • Consider optimizing your compiled code using a tool such as ProGuard. ProGuard identifies code that isn’t being used and removes it from your APK. Also enable resource shrinking at build time by setting minifyEnabled=true, shrinkResources=true in build.gradle—this automatically removes unused resources from your APK.
  • When using Google Play services, you should selectively include only the necessary APIs into your APK.
  • For more information on reducing code size in your APK, see the Android training on how to Avoid dependency injection frameworks.

Allow app to be moved to external (SD) storage

  • Low-cost devices often come with little on-device storage. Users can extend this with SD cards; however, apps need to explicitly declare that they support being installed to external storage before users can move them.
  • Allow your app to be installed to external storage using the android:installLocation flag in your AndroidManifest.xml. For more information on enabling your app to be moved to external storage, see the Android guide on App Install Location.

Reduce post-install app disk use

  • Keeping your app’s disk use low means that users are less likely to uninstall your app when the device is low on free space. It’s important to apply bounds around your caches—this prevents your app’s disk use from growing indefinitely. Be sure you put your cached data in getCacheDir()—the system can delete files placed here as needed, so they won’t show up as storage committed to the app.

Offer configurable network use

The Android platform includes a number of ways you can give the user control over your app's network use, optimizing it for their own needs. For example, on first use, your app can walk the user through a variety of network-related settings. You can also provide a network preferences screen from outside the app.

Provide onboarding experiences for users' network choices

  • Apps that allow users to reduce data use are well received, even if they have heavy data requirements. If your app uses a considerable amount of bandwidth (for example, video streaming apps), you can provide an onboarding experience for users to configure network use. For example, you could allow the user to force lower-bitrate video streams on cellular networks.
  • Additional settings for users to control data syncing, prefetching, and network use behavior (for example, prefetch all starred news categories on Wi-Fi only), also help users tailor your app’s behavior to their needs.
  • For more information on managing network use, see the Android training on Managing Network Usage.

Provide a network preferences screen

  • You can navigate to the app’s network settings from outside the app by means of a network preferences screen. You can invoke this screen from either the system settings screen or the system data usage screen.
  • To provide a network preferences screen that users can access from within your app as well as from the system settings, in your app include an activity that supports the ACTION_MANAGE_NETWORK_USAGE action.
  • For further information on adding a network preferences screen, see the Android training on Implementing a Preferences Activity.

Additional resources

To learn more about this topic, view the following additional resources:

Blog posts