Android 12 にアプリを移行する
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
このドキュメントでは、一般的な開発段階とテスト段階について概説し、プラットフォームのリリース スケジュールに沿って準備計画を立てるために役立つ情報を紹介します。それにより、Android 12 を使用するユーザーに快適なエクスペリエンスを提供できます。
Google は、Android をリリースするたびに、Android の利便性、安全性、パフォーマンスを高めることを目的とした新機能と動作変更を導入しています。多くの場合、アプリはそのままでも想定どおりに動作しますが、プラットフォームの変更に対応するためにアプリの更新が必要になる場合もあります。
AOSP(Android オープンソース プロジェクト)にソースコードがリリースされると、ユーザーはすぐに新しいプラットフォームの入手を開始できるので、それに向けて準備しておくことが重要です。アプリがユーザーの期待どおりに動作するだけでなく、新しい機能と API で新しいプラットフォームを最大限に活用できるようにするのが理想的です。
一般的な移行には、同時に進行できる次の 2 つの段階があります。
- アプリの互換性を確認する(Android 12 の最終リリースまでに完了)
- 新しいプラットフォームの機能と API をターゲットに設定する(最終リリース後、できるだけ早く完了)
Android 12 との互換性を確認する
既存のアプリの機能を Android 12 でテストすることは、Android の最新版にアップデートするユーザーに優れたエクスペリエンスを提供するために重要です。プラットフォームの変更の一部はアプリの動作に影響する可能性があるため、早い段階で徹底的にテストを行い、すべての必要な調整をアプリに加えることが重要です。
通常は、アプリの targetSdkVersion
を変更しなくても、アプリを調整してアップデートを公開できます。同様に、新しい API の使用や、アプリの compileSdkVersion
の変更は通常必須ではありません。ただし、それは、アプリのビルド方法や使用しているプラットフォームの機能によって異なります。
テストを開始する前に、すべてのアプリの動作変更を必ず確認するようにしてください。これらの変更は、targetSdkVersion
を変更しない場合もアプリに影響する可能性があります。
Android 12 システム イメージをデバイスにフラッシュするか、Android Emulator 用のシステム イメージをダウンロードします。
システムの動作変更を確認して、アプリが影響を受ける可能性がある領域を特定します。
デバイスまたはエミュレータにアプリをインストールして、テストを実施します。システムの動作変更に重点を置き、すべてのアプリフローを実行します。
動作変更への対応または問題の解決に必要なコード変更のみを行います。アプリが元来ターゲットとしていた API レベルで再コンパイルします。Android 12 をターゲットに設定する必要はありません。
Android App Bundle または APK に署名し、アップロードし、公開します。
互換性テストを実施する
Android 12 の互換性テストのほとんどの部分は、通常のアプリテストと同様です。この段階で、アプリの中核品質ガイドラインとテストに関するベスト プラクティスを確認することをおすすめします。
テストするには、Android 12 を搭載したデバイスに現在公開中のアプリをインストールし、すべてのフローと機能を実行して問題を探します。テストの対象を絞り込めるように、Android 12 で導入されたすべてのアプリの動作変更のうち、アプリの機能に影響するものとアプリのクラッシュを引き起こすものを確認します。
また、制限対象の非 SDK インターフェースを使用しているかどうかを確認し、テストします。アプリが使用している制限付きインターフェースは、すべて公開 SDK または NDK の同等のインターフェースに置き換える必要があります。その種のインターフェースへのアクセスを示す logcat 警告に注意し、StrictMode
メソッド detectNonSdkApiUsage()
を使用して、プログラムでそうしたアクセスを特定します。
最後に、アプリ内のライブラリと SDK の完全なテストを行い、Android 12 で想定どおりに動作することを確認します。また、プライバシー、パフォーマンス、UX、データ処理、権限に関するベスト プラクティスを適用します。問題が見つかった場合は、SDK を最新バージョンにアップデートするか、SDK のデベロッパーに対処方法を問い合わせます。
テストが完了し、必要なアップデートを加えたら、対応版のアプリをすみやかに公開することをおすすめします。そうすることで、Android 12 にアップデートしたときに、ユーザーがアプリを早めにテストしてスムーズに移行できます。
アプリのターゲティングを更新し、新しい API でビルドする
互換性のあるバージョンのアプリを公開した後、次のステップとして、targetSdkVersion
を更新することにより Android 12 の完全なサポートを追加し、Android 12 の新しい API と機能を利用できるようにします。新しいプラットフォームをターゲットに設定するための Google Play の要件を確認し、準備ができ次第、この更新を行うことができます。
Android 12 の完全なサポートに向けた作業を計画するにあたっては、Android 12 をターゲットとするアプリに影響する動作変更を確認します。これらのターゲット固有の動作変更によって機能的な問題が発生し、対処が必要になる場合があります。場合によっては大規模な開発が必要になるため、できるだけ早く確認して対処することをおすすめします。アプリに影響する動作変更を特定するため、互換性の切り替えで選択した変更を有効にしてアプリをテストできます。
Android 12 を完全にサポートするための手順を次に示します。
Android 12 でビルドするため、Android Studio プレビューの最新バージョンをインストールします。Android 12 のデバイスまたはエミュレータを用意します。
targetSdkVersion
およびその他のビルド構成を更新します。
Android 12 をターゲットとするアプリに適用される動作変更を確認します。アプリが影響を受ける領域を特定し、それに対応する方法を計画します。
Android 12 のユーザー プライバシーに関する変更に対応するために必要な変更をコードとアーキテクチャに加えます。
Android 12 の API を利用して、アプリに新しい機能を組み込みます。Android 12 に向けて再コンパイルします。
Android 12 のデバイスまたはエミュレータでテストします。動作変更がアプリに影響する可能性がある領域に集中して、新しい API を使用する機能を試します。プラットフォームと API に関するフィードバックを送信します。プラットフォーム、API、サードパーティの SDK に関する問題を報告します。
Android 12 の API 最終版が提供された時点で、targetSdkVersion
およびその他のビルド構成をもう一度更新し、追加の更新を行って、アプリをテストします。
Android App Bundle または APK に署名し、アップロードし、公開します。
SDK を入手し、ターゲット設定を変更し、新しい API を使ってビルドする
Android 12 の完全なサポートのテストを開始するには、Android Studio の最新プレビュー バージョンを使用して、Android 12 SDK とその他の必要なツールをダウンロードします。次に、アプリの targetSdkVersion
と compileSdkVersion
を更新し、アプリを再コンパイルします。詳しくは、SDK 設定ガイドをご覧ください。
Android 12 アプリをテストする
アプリをコンパイルして Android 12 搭載デバイスにインストールした後、Android 12 をターゲットに設定したときにアプリが正しく動作することを確認します。動作変更の中には、アプリが新しいプラットフォームをターゲットとする場合にのみ適用されるものがあります。テストを開始する前に、そのような変更を確認してください。
基本的な互換性テストを行う場合と同様に、すべてのフローと機能を実行して問題を探します。Android 12 をターゲットとするアプリに影響する動作変更に重点を置いてテストを進めます。この段階で、アプリの中核品質ガイドラインとテストに関するベスト プラクティスに対するアプリの対応状況をチェックすることをおすすめします。
制限対象となる非 SDK インターフェースを使用しているかどうかをテストして確認してください。こうしたアクセスを示す logcat 警告に注意し、StrictMode メソッド detectNonSdkApiUsage()
を使用して、プログラムによって特定します。
最後に、アプリ内のライブラリと SDK の完全なテストを行い、Android 12 で想定どおりに動作することを確認します。また、プライバシー、パフォーマンス、UX、データ処理、権限に関するベスト プラクティスを適用します。問題が見つかった場合は、SDK を最新バージョンにアップデートするか、SDK のデベロッパーに対処方法を問い合わせます。
アプリの互換性切り替えを使用してテストする
Android 12 は互換性の切り替えに対応しており、ターゲット固有の動作変更についてアプリを簡単にテストできます。デバッグ可能なアプリでは、この切り替えによって次のことが可能になります。
- アプリの targetSdkVersion を実際には変更せずに、ターゲット固有の変更をテストする。切り替えを使用して、特定のターゲット固有の動作変更を強制的に有効にし、既存のアプリに対する影響を評価できます。
- 特定の変更にテストを集中させる。切り替えを使用することで、テスト対象以外のターゲット固有の変更をすべて無効にできます。これにより、一度にすべてのターゲット固有の変更に対処する必要がなくなります。
- adb を介して切り替えを管理する。adb コマンドを使用すると、切り替え可能な変更を自動テスト環境で有効または無効にできます。
- 標準の変更 ID を使用して迅速にデバッグする。切り替え可能な変更にはそれぞれ一意の ID と名前が付けられており、ログ出力から問題の根本原因を速やかにデバッグできます。
アプリのターゲット設定を変更する場合や、Android 12 のサポートに向けて開発を行っているときは、この切り替え機能が役立ちます。詳しくは、互換性フレームワークの変更(Android 12)をご覧ください。
このページのコンテンツやコードサンプルは、コンテンツ ライセンスに記載のライセンスに従います。Java および OpenJDK は Oracle および関連会社の商標または登録商標です。
最終更新日 2025-08-21 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-08-21 UTC。"],[],[],null,["# Migrate apps to Android 12\n\n\u003cbr /\u003e\n\nThis document offers a high-level view of typical development and testing phases\nthat can help you make a plan for readiness that's well-aligned with the\nplatform release timeline and ensures a great experience for your users on\nAndroid 12.\n\nWith each release of Android, we introduce new features as well as behavior\nchanges aimed at making Android more helpful, more secure, and more performant.\nIn many cases your app will work exactly as expected out-of-the-box, while in\nother cases you might need to update your app to adapt to the platform changes.\n\nUsers can start receiving the new platform as soon as the source code is\nreleased to AOSP (Android Open Source Project), so it's important for your apps\nto be ready, performing as expected for users and ideally taking advantage of\nnew features and APIs to get the most out of the new platform.\n\nA typical migration has two phases, which can be concurrent:\n\n- Ensuring app compatibility (by Android 12 final release)\n- Targeting the new platform features and APIs (as soon as possible after final release)\n\nEnsure compatibility with Android 12\n------------------------------------\n\nIt's important to test the functionality of your existing app against\nAndroid 12 to ensure a great experience for users updating to the\nlatest version of Android. Some platform changes can affect the way your app\nbehaves, so it's important to test early and thoroughly and make any needed\nadjustments to your app.\n\nYou can usually adjust your app and publish an update without needing to change\nthe app's `targetSdkVersion`. Similarly, you shouldn't need to use new APIs or\nchange the app's `compileSdkVersion`, although this can depend on the way your\napp is built and the platform functionality it's using.\n\nBefore you start testing, be sure to familiarize yourself with the [behavior\nchanges for all apps](/about/versions/12/behavior-changes-all). These changes might affect your app, even if you don't\nchange its `targetSdkVersion`. \nGet Android 12 \nFlash an Android 12 system image to your device, or download\na system image for the Android emulator. \nReview changes \nReview system behavior changes to identify areas where your app\nmight be affected. \nTest \nInstall your app on your device or emulator, and run tests. Focus\non system behavior changes, and work through all app flows. \nUpdate \nMake only the code changes required to adapt to behavior\nchanges or resolve issues. Recompile with the same API level\nthat your app originally targeted - no need to target Android 12. \nPublish \nSign, upload, and publish your updated Android App Bundle\nor APK.\n\n### Perform compatibility testing\n\nFor the most part, testing compatibility with Android 12 is\nsimilar to ordinary app testing. This is a good time to review the [core app\nquality guidelines](/develop/quality-guidelines/core-app-quality) and [best practices for testing](/training/testing).\n\nTo test, install your current published app on a device running\nAndroid 12, and work through all the flows and functionality\nwhile looking for issues. To help you focus your testing,\n**review the [behavior changes for all apps](/about/versions/12/behavior-changes-all)** introduced in\nAndroid 12 that can affect how your app functions or cause your\napp to crash.\n\nAlso make sure to **review and test for uses of [restricted non-SDK\ninterfaces](/about/versions/12/non-sdk-12)** . You should replace any restricted interface your app uses with\na public SDK or NDK equivalent. Watch for logcat warnings that highlight these\naccesses, and use the `StrictMode` method [`detectNonSdkApiUsage()`](/reference/android/os/StrictMode.VmPolicy.Builder#detectNonSdkApiUsage()) to catch\nthem programmatically.\n\nLast, make sure to fully **test the libraries and SDKs in your app** to make\nsure they work as expected on Android 12 and follow best\npractices for privacy, performance, UX, data handling, and permissions. If you\nfind an issue, try updating to the latest version of the SDK, or reach out to\nthe SDK developer for help.\n\nWhen you've finished your testing and made any updates, we recommend publishing\nyour compatible app right away. This lets your users test the app early and\nhelps ensure a smooth transition for your users as they update to\nAndroid 12.\n\nUpdate the app's targeting and build with new APIs\n--------------------------------------------------\n\nOnce you've published a compatible version of your app, the next step is to add\nfull support for Android 12 by updating its `targetSdkVersion`\nand taking advantage of new APIs and capabilities in Android 12.\nYou can make these updates as soon as you're ready, keeping in mind the [Google\nPlay requirements](/distribute/play-policies) for targeting the new platform.\n\nAs you plan your work to fully support Android 12, review the\n[behavior changes that affect apps targeting Android 12](/about/versions/12/behavior-changes-12).\nThese *targeted behavior changes* might cause functional issues you then need to\naddress. In some cases, these changes require significant development, so we\nrecommend learning about and addressing them as early as possible. To help\nidentify specific behavior changes that affect your app, use the [compatibility\ntoggles](/about/versions/12/migration#using_app_compatibility_toggles) to test your app with selected changes enabled.\n\nThe following steps describe how to fully support Android 12. \nGet Android 12 SDK \nInstall the latest version of Android Studio preview to build\nwith Android 12. Make sure you have an Android 12 device or\nemulator. \n\nUpdate your `targetSdkVersion` and other build\nconfigurations. \nReview behavior changes \nReview the behavior changes that apply to apps targeting\nAndroid 12. Identify areas where your app might be affected,\nand plan how to support them. \nCheck against new privacy changes \nMake code and architecture changes needed to support Android 12's\nuser privacy changes. \nAdopt Android 12 features \nTake advantage of Android 12 APIs to bring new features and\ncapabilities to your apps. Recompile for Android 12. \nTest \nTest on an Android 12 device or emulator. Focus on areas\nwhere behavior changes might affect your app. Try out\nfunctionality that uses new APIs. Provide platform and API\nfeedback. Report any platform, API, or third-party SDK issues. \nFinal update \nOnce Android 12 APIs are final, update your\n`targetSdkVersion` and other build configurations\nagain, make any additional updates, and test your app. \nPublish \nSign, upload, and publish your updated Android App Bundle\nor APK.\n\n### Get the SDK, change targeting, build with new APIs\n\nTo start testing for full Android 12 support, use the latest\npreview version of Android Studio to download the Android 12 SDK\nand any other tools you need. Next, update your app's `targetSdkVersion` and\n`compileSdkVersion`, and re-compile the app. See the [SDK setup guide](/about/versions/12/setup-sdk) for\ndetails.\n\n### Test your Android 12 app\n\nOnce you've compiled the app and installed it on a device running\nAndroid 12, begin testing to ensure that the app works properly\nwhen targeting Android 12. Some behavior changes apply only when\nyour app is targeting the new platform, so you'll want to [review those\nchanges](/about/versions/12/behavior-changes-12) before getting started.\n\nAs with basic compatibility testing, work through all the flows and\nfunctionality looking for issues. Focus your testing on the\n**[behavior changes for apps targeting Android 12](/about/versions/12/behavior-changes-12)** . It's\nalso a good time to check your app against the [core app quality guidelines](/develop/quality-guidelines/core-app-quality)\nand [best practices for testing](/training/testing).\n\nMake sure to review and **test for uses of [restricted non-SDK interfaces](/about/versions/12/non-sdk-12)**\nthat may apply. Watch for logcat warnings that highlight these accesses and use\nthe StrictMode method [`detectNonSdkApiUsage()`](/reference/android/os/StrictMode.VmPolicy.Builder#detectNonSdkApiUsage()) to catch them\nprogrammatically.\n\nLast, make sure to fully **test the libraries and SDKs in your app** to make\nsure they work as expected on Android 12 and follow best\npractices for privacy, performance, UX, data handling, and permissions. If you\nfind an issue, try updating to the latest version of the SDK, or reach out to\nthe SDK developer for help.\n\n### Test using app compatibility toggles\n\nAndroid 12 includes compatibility toggles that make it easier to test your app\nwith targeted behavior changes. For a debuggable app, the toggles let you:\n\n- **Test targeted changes without actually changing the app's\n targetSdkVersion**. You can use the toggles to force-enable specific targeted behavior changes to evaluate the impact on your existing app.\n- **Focus your testing on specific changes only**. Rather than having to address all targeted changes at once, the toggles let you disable all targeted changes except the ones you want to test against.\n- **Manage toggles through adb**. You can use adb commands to enable and disable the toggleable changes in your automated test environment.\n- **Debug faster using standard change IDs**. Toggleable changes each have a unique ID and name that you can use to quickly debug root cause in log output.\n\nAs you prepare for changing your app's targeting, or while you in active\ndevelopment for Android 12 support, the toggles can help. For more information,\nsee [Compatibility framework changes (Android 12)](/about/versions/12/reference/compat-framework-changes)."]]