Version: 2023.1
言語: 日本語
Android 用の開発を始める
Android Player 設定

Android 用の環境設定

Android 用 Unity アプリケーションの作成にあたっては、Android をサポートするように Unity プロジェクトを設定する必要があります。Unity プロジェクトは、Android をサポートするために以下の依存関係を必要とします。

  • Android Build Support モジュール
  • The Android Software Development Kit (SDK).
  • The Native Development Kit (NDK).
  • Java Development Kit (デフォルトでは、Unity は OpenJDK を使用します。)

開発を始める前に、Android の要件と互換性に関する Unity ドキュメント を参照し、Android 用の Unity アプリケーション開発に関わる制約事項を確認してください。

依存関係のインストール

Unity distributes dependencies as modules which means you must use the Unity Hub to install them. You can install them either when you install a new Unity Editor version, or add them to an existing Unity Editor install. To install modules:

インストールするモジュールは以下の 3 つです。

  • Android Build Support
  • Android SDK & NDK Tools
  • OpenJDK
Unity Hub に表示された 3 つの依存関係モジュール
Unity Hub に表示された 3 つの依存関係モジュール

Unity installs Android SDK & NDK Tools and OpenJDK respectively in the SDK, NDK, and OpenJDK folders under /[EditorVersion]/Editor/Data/PlaybackEngines/AndroidPlayer/.

依存関係のカスタマイズ

Android SDK & NDK ToolsOpenJDK のインストールは、正しいバージョンと設定をインストールするために、Unity Hub を使用して行う必要があります。ただし、Unity が Android 用アプリケーションの構築に使用する SDK、NDK、JDK を変更することが有用な場合もあります。例えば、同じ依存関係を持つ複数のバージョンの Unity があり、SDK、NDK、JDK のインストールを重複させたくない場合には、共有の場所を指定することもできます。

Unity にカスタムバージョンの依存関係を使用させるには、以下を行ってください。

  1. Download the custom version of the dependency.
    Warning: Unity only officially supports versions of the OpenJDK, SDK, or NDK that it supplies through the Hub. For more information, refer to Supported dependency versions.
  2. In Unity’s main menu, go to Edit > Preferences > External Tools > Android (macOS: Unity > Settings > External Tools > Android)
  3. Refer to the External tools for Android documentation to understand how to customize the installation of JDK, SDK, NDK, and Gradle.

サポートされている依存関係のバージョン

このセクションには、Unity の各バージョンが、各依存関係のどのバージョンをサポートしているかについての情報が含まれています。Unity はバージョンごとに特定のバージョンの Android NDK および Android JDK を必要としますが、Android SDK に関しては厳密なバージョン要件はありません。

SDK

Unity relies on tools that the Android SDK provides and different versions of the SDK usually have the same tools available. This means you can use any recent version of the SDK as they all contain the build tools that Unity requires.

The following table shows the supported versions of Android SDK tools installed with each Unity version:

Unity バージョン SDK tools version SDK Build tools version SDK Command-line tools version SDK Platform tools version
2023.1 26.1.1 32.0.0 6 33.0.1
2022.3 LTS 26.1.1 32.0.0 6 32.0.0
2021.3 LTS 26.1.1 30.0.2 2 30.0.4
2020.3 LTS 26.1.1 30.0.2 2 28.0.1

Important: Unity versions 2020.3 and 2021.3 LTS don’t support Android SDK Build tools versions 31 and above.

NDK

Unity の各バージョンがサポートする NDK のバージョンは、以下の通りです。

Unity バージョン NDK バージョン
2023.1 r23b(23.1.7779620)
2022.3 LTS r23b(23.1.7779620)
2021.3 LTS r21d(21.3.6528147)
2020.3 LTS r19(19.0.5232133)
JDK

Unity の各バージョンがサポートする JDK のバージョンは、以下の通りです。

Unity バージョン JDK バージョン
2023.1 11 (OpenJDK バージョン 11)
2022.3 LTS 11 (OpenJDK バージョン 11)
2021.3 LTS 8 (OpenJDK バージョン 1.8)
2020.3 LTS 8 (OpenJDK バージョン 1.8)

Note: Only Unity version 2023.1 supports CMake version 3.22.1. Unity versions 2022.3 and below do not support CMake.

External Tools for Android

The External Tools section for Android allows you to configure settings for Android development tools used to set up Unity projects on Android devices. To access the External Tools for Android section, in the Preferences window (macOS: Unity > Settings >), go to Edit > Preferences > External Tools > Android.

For general Preferences settings, refer to Preferences.

External Tools for Android
External Tools for Android
設定 説明 
JDK installed with Unity(recommended) Indicates whether to use the recommended version of Java Development Kit (JDK) installed with Unity or the custom JDK installation. If enabled, the setting displays the path to the JDK installation folder. To use the custom JDK version, disable this option and click Browse to set the custom JDK installation folder path.
Android SDK tools installed with Unity(recommended) Indicates whether to use the recommended versions of Android SDK tools installed with Unity or the custom SDK tools installation. If enabled, the setting displays the path to the SDK tools installation folder. To use the custom SDK tools version, disable this option and click Browse to set the custom SDK tools installation folder path.
Android NDK installed with Unity(recommended) Indicates whether to use the recommended version of Android Native Development Kit (NDK) installed with Unity or the custom NDK installation. If enabled, the setting displays the path to the NDK installation folder. To use the custom NDK version, disable this option and click Browse to set the custom NDK installation folder path.
Gradle installed with Unity(recommended) Indicates whether to use the recommended version of Android Gradle installed with Unity or the custom Gradle installation. If enabled, the setting displays the path to the Gradle installation folder. To use the custom Gradle version, disable this option and click Browse to set the custom Gradle installation folder path.
Stop Gradle daemons on exit Indicates whether to stop Gradle daemons when the Unity Editor exits. This option is enabled by default and it might help to free up resources on your computer.
Kill ADB server on exit Indicates whether to terminate Android Debug Bridge (adb) server when the Unity Editor exits. This option is enabled by default and it might help to free up resources on your computer.
Maximum JVM heap size, Mbyte Specifies the maximum Java heap size that can be allocated during the Android build process. The value is specified in megabytes and the default value is 4096. You can increase or decrease this value based on your project requirement. Increase this value if you experience heap space errors.
Keystores Dedicated Location Specifies the folder path to your Android keystores. Unity uses this path when signing your Android application during the build process. To set a new path for your application, click Browse and navigate to the folder where you want to store your Android keystores. For more information, refer to Choose the keystore location.

Android SDK Target API の設定

Unity Hub は、Google Play の要求する Android SDK Target API の最新バージョンをインストールします。より新しいバージョンを使用する必要がある場合は Android の Player 設定 で変更可能です。これは以下の手順で行えます。

  1. Edit > Project Settings を選択します。
  2. Project Settings ウィンドウで Player タブを選択し、以下の画像のように Android の Player 設定 を開きます。
    Android SDK のターゲット API の選択
  3. Other Settings セクションで Target API Level を変更してください。

インストールされている最新のバージョンよりも新しいバージョンのターゲット API を選択した場合、Unity Android SDK Updater は、新しいバージョンのダウンロードとインストールを自動で行うことができます。Unity によってプロンプトが表示され、以下のいずれかの方法を選択できます。

  • 新しいバージョンの Android SDK を自動的にダウンロードおよびインストールする
  • インストールされている中で最新のバージョンの Android SDK を引き続き使用する

If you select a target API version that isn’t installed and is older than the latest installed version, the Unity Android SDK Updater can’t perform the update and Unity displays an error message. In this case, to update the Android SDK Target API, you must use the Android sdkmanager from either Android Studio or the command-line tool. Regardless of the method you choose, make sure to select the correct Android SDK folder for Unity in the Edit > Preferences > External Tools window. For more information, refer to Customizing dependencies.

Important: On Windows, if you installed the Unity Editor in the default folder (/Program Files/), you must run the sdkmanager with elevated privileges (Run as Administrator) to perform the update.

ChromeOS

Unity では、ChromeOS は Android 開発環境の一部です。つまり、新規および既存の Android アプリケーションを ChromeOS に公開できます。また、多くの ChromeOS デバイスはノートパソコン (あるいはノートパソコンモード付き) なので、マウスやキーボード入力などの機能を使用することができます。詳細は以下を参照してください。

Android 用の開発を始める
Android Player 設定