# Android アプリマニフェスト

> Introduces Unity Library Manifests and explains how Unity uses them to generate the final Android App Manifest for an application.

Android アプリマニフェストには、Android アプリケーションに関する情報が含まれています。各アプリケーションは、[ソースセット](https://developer.android.com/studio/build#sourcesets) のルートに `AndroidManifest.xml` という Android アプリマニフェスト [XML](https://en.wikipedia.org/wiki/XML) ファイルを 1 つ持ちます。Android OS とデジタル分布サービス (例えば Google Play) は、Android アプリマニフェストを使用して、アプリケーション名、アプリケーションの [エントリーポイント](https://developer.android.com/guide/components/activities/intro-activities)、Android バージョンのサポート、ハードウェア機能のサポート、アプリケーションの権限などの情報を検索します。Android アプリマニフェストファイルの詳細と、それが構成する設定のリストについては、[Android アプリマニフェスト](https://developer.android.com/guide/topics/manifest/manifest-intro.html) に関する Android Developer のドキュメントを参照してください。

アプリケーションを表す Android アプリマニフェストを生成するために、Gradle はさまざまなソースのマニフェストファイルをマージします。これには次が含まれます。

* **Unity ライブラリマニフェスト**: Unity Player アクティビティを設定する Unity が生成するマニフェストファイル。詳細については、[Unity ライブラリマニフェスト](/engine/6000.0/manual/platform-specific/android/introducing/library-manifest.md) を参照してください。
* **Unity Launcher Manifest**: Unity ライブラリをラップするアプリケーションを設定する Unity が生成するマニフェストファイル。詳細については、[Unity Launcher Manifest](/engine/6000.0/manual/platform-specific/android/introducing/launcher-manifest.md) を参照してください。
* **プラグインマニフェスト**: Android Archive (AAR) や Android ライブラリプロジェクトなどのプラグインを表すマニフェストファイル。

Unity がこれらのマニフェストファイルを使用して Android アプリマニフェストを生成する方法については、[Android アプリマニフェストの生成](#generating-an-android-manifest) を参照してください。

## Android アプリマニフェストの生成##generating-an-android-app-manifest

[Android アプリケーションビルドプロセス](/engine/6000.0/manual/platform-specific/android/introducing/how-unity-builds-android-applications.md) は、アプリケーションの Android アプリマニフェストファイルを生成します。手順は以下のとおりです。

1. Unity は、Unity ライブラリマニフェストを Android アプリマニフェストのテンプレートとして使用します。[Unity ライブラリマニフェストをオーバーライド](/engine/6000.0/manual/platform-specific/android/building-and-delivering/modify-gradle-project-files/templates.md) すると、Unity は指定したファイルをテンプレートとして使用します。
2. Unity は、Unity ライブラリマニフェストファイルと Unity Launcher Manifest ファイルを、[権限](#permissions)、設定オプション、アプリケーションが使用する機能などの情報で更新します。
3. [Gradle](/engine/6000.0/manual/platform-specific/android/introducing/gradle-overview.md) は、Unity ライブラリマニフェスト、Unity Launcher Manifest、およびプラグインマニフェストを、1 つの Android アプリマニフェストファイル内にマージします。

出力された Android App Bundle (AAB) または Android パッケージ (APK) 内の Android アプリマニフェストファイルは、[Android Studio APK Analyzer](https://developer.android.com/studio/build/apk-analyzer.html)、または [Apktool](https://ibotpeaches.github.io/Apktool/) などのサードパーティ製のツールを使用して表示できます。

**重要**: APK または AAB 内の Android アプリマニフェストファイルは編集できません。Android アプリマニフェストのコンテンツをオーバーライドする方法については、[Gradle プロジェクトファイルの変更](/engine/6000.0/manual/platform-specific/android/building-and-delivering/modify-gradle-project-files.md) を参照してください。

## パーミッション##permissions

Unity は、[Android Player 設定](/engine/6000.0/manual/platform-specific/android/getting-started/class-player-settings.md) と、アプリケーションが C# スクリプトから呼び出す Unity API に基づいて、マニフェストに必要な権限を自動的に加えます。 例:

* 以下のクラス、パッケージ、および Player 設定は、`INTERNET` 権限を追加します。

  * 開発ビルドの [Android Player 設定](/engine/6000.0/manual/platform-specific/android/getting-started/class-player-settings.md#Configuration) で **Internet Access** を **Require** に設定する
  * [UnityWebRequest](/engine/6000.0/script-reference/unity-engine-networking/unity-web-request.md) クラスと [Ping](/engine/6000.0/script-reference/unity-engine/ping.md) クラス
  * [System.Net.Sockets](https://learn.microsoft.com/en-us/dotnet/api/system.net.sockets.socket?view=net-8.0) API
  * [Unity Analytics](https://docs.unity.com/ugs/manual/analytics/manual/overview.md) パッケージと、[Cloud Diagnostics パッケージ](https://docs.unity.com/ugs/manual/cloud-diagnostics/manual/CloudDiagnostics/WelcometoCloudDiagnostics.md) の**クラッシュと例外レポート**

* 振動 ([Handheld.Vibrate](/engine/6000.0/script-reference/unity-engine/handheld/vibrate.md) など) を使用すると、`VIBRATE` が追加されます。

* [InternetReachability](/engine/6000.0/script-reference/unity-engine/application/internet-reachability.md) プロパティは `ACCESS_NETWORK_STATE` を追加します。

* 位置情報 API ([LocationService](/engine/6000.0/script-reference/unity-engine/location-service.md) など) は `ACCESS_FINE_LOCATION` を追加します。

* [WebCamTexture](/engine/6000.0/script-reference/unity-engine/web-cam-texture.md) API は `CAMERA` を追加します。

* [Microphone](/engine/6000.0/script-reference/unity-engine/microphone.md) クラスは `RECORD_AUDIO` を追加します。

プラグインがそのマニフェストで宣言している権限を要求している場合、Unity は、Gradle のマージの段階で、最終的な Android アプリマニフェストにその権限を自動的に追加します。Unity は、プラグインが権限リストで使用するすべての Unity API を追加することに注意してください。

Android アプリマニフェストで権限を指定する代わりに、Android [ランタイムパーミッションシステム](https://developer.android.com/training/permissions/requesting.html) を使用して [ランタイムに権限をリクエスト](/engine/6000.0/manual/platform-specific/android/developing/device-features-and-permissions/requesting-permissions.md) できます。

権限の詳細については、[Android アプリマニフェストの権限](https://developer.android.com/guide/topics/manifest/manifest-intro.html#perms) に関する Android Developer のドキュメントを参照してください。
