何十億人ものユーザーのデータコストを削減
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
データプランのコストは、一部の国では標準的なユーザーの月収の 10% を超える可能性があります。つまり、アプリのダウンロード サイズを最小限に抑え、アプリによるデータの使用方法をユーザー側でコントロールすることで、ユーザーは大きなメリットを得られます。また、ダウンロード サイズを最小限に抑えることで、一部のデバイスにとっては希少な内部ストレージの容量を節約することもできます。
ネットワーク上と内部ストレージ内の両方でアプリが使用するデータ量を最適化するための戦略を以下に示します。
アプリのサイズを削減する
アプリのサイズを削減することは、ネットワーク データと内部ストレージの両面において、ユーザーのデータ使用量を抑える基本的な方法の 1 つです。このセクションでは、アプリのサイズを縮小するいくつかの方法について説明します。
APK のグラフィカルなアセットのサイズを縮小する
- 多くの場合、グラフィカルなアセットは APK のサイズに最も大きく影響します。グラフィカルなアセットを最適化すると、ダウンロード サイズが削減されるため、ユーザーによるインストール時間を短縮できます。
- アイコンなどのグラフィック アセットの場合は、Scalable Vector Graphics(SVG)形式を使用します。SVG 画像はビットマップ グラフィックに比べてサイズが小さく、実行時に任意の解像度でレンダリングできます。Android サポート ライブラリを使うことで、ベクター リソースに対する下位互換性のある実装を Android 2.1(API レベル 7)で実現できます。
ベクターの使い方は、こちらの Medium の投稿をご覧ください。
- 写真など、ベクター以外の画像には WebP を使用して画像の読み込み時間を短縮し、ネットワーク帯域幅を節約します。WebP は、PNG や JPG で提供した場合よりもファイルサイズが小さくなり、しかも画質は同じです。不可逆圧縮の設定でも、WebP は元の画像とほぼ同等の画像を生成できます。Android 4.0(API レベル 14: Ice Cream Sandwich)以降では、不可逆圧縮の WebP サポートの対象となり、Android 4.2(API レベル 17: Jelly Bean)以降では、WebP は可逆圧縮と透明度に対応しています。
- サイズの大きい画像を多数使用し、複数の密度に対応する場合は、マルチ APK のサポートを使用して密度ごとに APK をスプリットすることを検討してください。この方法では特定の密度を対象にしたビルドが可能になるため、低密度のデバイスを使用するユーザーが、使用しない高密度のアセットをダウンロードする必要は生じません。
- APK のサイズを小さくする方法について詳しくは、APK のサイズを小さくするおよびコードとリソースの圧縮をご覧ください。また、こちらの Medium の一連の記事で、APK のサイズを小さくする方法に関する詳細なガイドをご覧ください。
コードサイズを小さくする
- Android プロジェクト内のライブラリはどれも、使用されない可能性のあるコードを APK に追加します。外部ライブラリは、モバイルアプリで使用するように常に設計されているわけではないため、特に注意が必要です。アプリで使用しているライブラリが、モバイルでの使用に合わせて最適化されていることを確認してください。
- ProGuard などのツールを使用してコンパイルしたコードを最適化することを検討してください。ProGuard は、未使用のコードを特定して APK から削除します。また、
build.gradle
で minifyEnabled=true
、shrinkResources=true
を設定することで、ビルド時にリソース圧縮を有効化します。これにより、未使用のリソースが APK から自動的に削除されます。
- Google Play 開発者サービスを使用するときは、必要な API のみを APK に選択的に含める必要があります。
- APK のコードサイズの削減については、依存関係挿入フレームワークの回避に関する Android トレーニングをご覧ください。
外部ストレージ(SD)へのアプリの移動を許可する
- 低コストのデバイスでは、デバイス上のストレージが不足する場合がよくあります。ユーザーは SD カードを使用してストレージを拡張できます。ただし、ユーザーが外部ストレージに移動する前に、外部ストレージへのインストールをサポートしていることをアプリで明示的に宣言する必要があります。
- AndroidManifest.xml で
android:installLocation
フラグを使用して、外部ストレージにアプリをインストールできるようにします。外部ストレージへのアプリの移動を有効にする方法について詳しくは、アプリのインストール場所に関する Android ガイドをご覧ください。
インストール後のアプリのディスク使用量を削減する
- アプリのディスク使用量を少なく抑えることができれば、デバイスの空き容量が少なくなったときにユーザーがアプリをアンインストールする可能性が低くなります。キャッシュへの保存に上限を設けることが重要です。そうすれば、アプリのディスク使用が際限なく拡大するのを防ぐことができます。キャッシュに保存したデータは
getCacheDir()
で取得した場所に格納してください。ここに配置されたファイルはシステムが必要に応じて削除できるため、アプリ側で利用できるストレージとして認識されることはありません。
構成可能なネットワーク使用を提供する
Android プラットフォームには、ユーザーがアプリのネットワーク使用を制御でき、ユーザー独自のニーズに合わせて最適化する方法がいくつかあります。たとえば、アプリの初回使用時に、ネットワーク関連の各種設定をユーザーに提示できます。
アプリの外部からネットワーク設定画面を指定することもできます。
ユーザーのネットワーク選択に合わせて開始画面を提供する
- データ通信量が多いアプリであっても、ユーザー側で通信量を削減できるようにすることで、ユーザーの評価は上がります。動画ストリーミング アプリなど、アプリが大量の帯域幅を使用する場合、ネットワークの使用を構成できる利用開始画面を提供できます。たとえば、モバイル ネットワークでは低ビットレートの動画ストリームをユーザーが強制的に選べるようにします。
- データの同期、プリフェッチ、ネットワークの使用動作を制御するための追加設定(たとえば、Wi-Fi でのみスター付きニュース カテゴリをすべてプリフェッチするなど)によって、ユーザーが自分のニーズに合わせてアプリの動作を調整できるようになります。
- ネットワークの使用の管理について詳しくは、ネットワーク使用状況の管理に関する Android トレーニングをご覧ください。
ネットワークの設定画面を提供する
- ネットワークの設定画面を使用すると、アプリの外部からアプリのネットワーク設定に移動できます。この画面は、システム設定画面またはシステムデータ使用量画面のいずれかから呼び出すことができます。
- ユーザーが、アプリ内だけでなく、システム設定からもアクセスできるネットワーク設定画面を提供するには、
ACTION_MANAGE_NETWORK_USAGE
アクションをサポートするアクティビティをアプリに含めます。
- ネットワークの設定画面の追加については、設定アクティビティの実装に関する Android トレーニングをご覧ください。
参考情報
このトピックの詳細については、次のリソースをご覧ください。
ブログ投稿
このページのコンテンツやコードサンプルは、コンテンツ ライセンスに記載のライセンスに従います。Java および OpenJDK は Oracle および関連会社の商標または登録商標です。
最終更新日 2025-07-27 UTC。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["必要な情報がない","missingTheInformationINeed","thumb-down"],["複雑すぎる / 手順が多すぎる","tooComplicatedTooManySteps","thumb-down"],["最新ではない","outOfDate","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["サンプル / コードに問題がある","samplesCodeIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-07-27 UTC。"],[],[],null,["# Reduced data cost for billions\n\n\u003cbr /\u003e\n\n\nData plans in some countries can cost upwards of 10% of a typical user's monthly income. This\nmeans that minimizing your app's download size and letting the user control how your app uses\ndata can have a large, tangible benefit to many users. Minimizing download size also helps\nconserve space in internal storage, which is a scarce resource in some devices.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\nHere you can find some strategies to help optimize the amount of data your app uses, both over\nthe network and in internal storage.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nReduce app size\n---------------\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\nReducing app size is one of the fundamental ways you can help your user consume less data, in\nterms of both network data and internal storage. This section describes several approaches to\nreducing app size.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n### Reduce APK graphical asset size\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n- 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.\n- 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](/tools/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](https://medium.com/@chrisbanes/appcompat-v23-2-age-of-the-vectors-91cbafa87c88).\n- For non-vector images, such as photos, use [WebP](https://developers.google.com/speed/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).\n- If you have many large images across multiple densities, consider using [Multiple\n APK support](/google/play/publishing/multiple-apks) 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.\n- For more information about reducing APK size, see [Reduce APK Size](/topic/performance/reduce-apk-size) and [Shrink Your Code and Resources](/studio/build/shrink-code). In addition, you can find a detailed guide on reducing APK size in this [series of Medium posts](https://medium.com/@wkalicinski/smallerapk-part-4-multi-apk-through-abi-and-density-splits-477083989006).\n\n### Reduce code size\n\n- 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.\n- Consider optimizing your compiled code using a tool such as [ProGuard](/tools/help/proguard). ProGuard identifies code that isn't being used and removes it from your APK. Also [enable resource shrinking](http://tools.android.com/tech-docs/new-build-system/resource-shrinking) at build time by setting `minifyEnabled=true`, `shrinkResources=true` in `build.gradle`---this automatically removes unused resources from your APK.\n- When using Google Play services, you should [selectively include](/google/play-services/setup#add_google_play_services_to_your_project) only the necessary APIs into your APK.\n- For more information on reducing code size in your APK, see the Android training on how to [Avoid\n dependency injection frameworks](/training/articles/memory#DependencyInjection).\n\n### Allow app to be moved to external (SD) storage\n\n- 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.\n- Allow your app to be installed to external storage using the [`\n android:installLocation`](/guide/topics/manifest/manifest-element#install) 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\n Location](/guide/topics/data/install-location).\n\n\u003cbr /\u003e\n\n### Reduce post-install app disk use\n\n\u003cbr /\u003e\n\n- 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()](/reference/android/content/Context#getCacheDir())---the system can delete files placed here as needed, so they won't show up as storage committed to the app.\n\n\u003cbr /\u003e\n\nOffer configurable network use\n------------------------------\n\n\nThe Android platform includes a number of ways you can give the user control\nover your app's network use, optimizing it for their own needs. For example,\non first use, your app can walk the user through a variety of network-related settings.\nYou can also provide a network preferences screen from outside the app.\n\n### Provide onboarding experiences for users' network\nchoices\n\n\u003cbr /\u003e\n\n- 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.\n- 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.\n- For more information on managing network use, see the Android training on [Managing\n Network Usage](/training/basics/network-ops/managing).\n\n### Provide a network preferences\nscreen\n\n- 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.\n- 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](/reference/android/content/Intent#ACTION_MANAGE_NETWORK_USAGE) action.\n- For further information on adding a network preferences screen, see the Android training on [Implementing a Preferences Activity](/training/basics/network-ops/managing#prefs).\n\n\u003cbr /\u003e\n\nAdditional resources\n--------------------\n\nTo learn more about this topic, view the following additional resources:\n\n### Blog posts\n\n- [Nurture trust through cost transparency](https://medium.com/google-design/nurture-trust-through-cost-transparency-b61a5947d2fc)"]]