Android での開発を始める
Unity Remote

Android environment setup

Whether you’re building an Android application in Unity or programming it from scratch, you must set up the Android Software Development Kit (SDK) before you can build and run any code on your Android device.

1. Install the Java Development Kit

Download and install the Java Development Kit (JDK). Unity requires the 64-bit version JDK 8 (1.8).

2. Download the Android SDK

You can install the Android SDK using command line tools or through Android Studio. Android Studio provides an easy to use GUI based tool, but installs additional software on your computer. Using the command line tools is a smaller download and does not install additional software, but it can be more challenging to use.

2a. Install the Android SDK using the command line tools

Install or unpack the Android SDK. After installing, open the Android SDK Manager and add: at least one Android SDK Platform, the Platform Tools, the Build Tools, and the USB drivers if you’re using Windows.

To install an Android platform SDK and the associated tools:

  1. Download the Android Software command line tool.

  2. Unzip the tools folder to a location on your hard drive.

  3. Open a command-prompt window.

  4. Navigate to the bin folder in the location where you unzipped the tools folder: “install folder” > tools > bin

  5. Use the sdkmanager command line tool to retrieve the list of packages that you can install. The installable packages include the Platform SDKs, Build Tools, Platform tools, and other tools.

sdkmanager –list

  1. Select a version of the Platform SDK to install. Platform SDKs take the following form in the list: platforms;android-xx. The xx indicates the SDK level. The larger the number, the newer the package. Typically, you can install the latest available version. But, there might be cases in which Google has released a new version of the SDK that causes errors when you build your Unity Project. In that case you must uninstall the SDK and install an earlier version. The general format of the command for package installation is sdkmanager <package name>. You can install the corresponding Platform Tools and Build Tools at the same time.

    Example: sdkmanager “platform-tools” “platforms;android–27” “build-tools;27.0.3”

  2. If you are running on Windows, install the USB device drivers.

sdkmanager “extras;google;usb_driver”

This installs the SDK in a directory named “platforms” in the directory in which you unzipped the tools folder. Example: c:\<install folder>\platforms

2b. Install the SDK using Android Studio

Install Android studio from the Android developer portal. The Android developer portal provides detailed installation instructions.

Note: Android Studio provides some ease of use benefits, but it is not fully tested for compatibility with Unity installs. If you encounter errors, Unity recommends using the command line method.

When installing the Android platform SDK and other tools, you can typically install the latest available version. There might be cases in which Google has released a new version of the SDK that causes errors when you build your Unity Project. In that case you must uninstall the SDK and install an earlier version.

Install the associated Platform and Build tools at the same time. If you are running on Windows, install the USB device drivers.

3. デバイスの USB デバッグを有効にする

To enable USB debugging, you must enable Developer options on your device. To do this, find the build number in your device’s Settings menu. The location of the build number varies between devices. The stock Android setting can be found by navigating to Settings > About phone > Build number. For specific information on your device and Android version, refer to your hardware manufacturer.

Samsung Galaxy Note 3 の Android5.0 (Lollipop) で表示されたビルド番号
Samsung Galaxy Note 3 の Android5.0 (Lollipop) で表示されたビルド番号

Note: On Android versions prior to 4.2 (Jelly Bean), the Developer options aren’t hidden. Go to Settings > Developer options, then enable USB debugging.

After you navigate to the build number using the instructions above, tap on the build number seven times. A pop-up notification saying “You are now X steps away from being a developer” appears, with “X” being a number that counts down with every additional tap. On the seventh tap, Developer options are unlocked.

Connect your device to your computer using a USB cable. If you are developing on a Windows computer, you might need to install the a device specific USB driver. See the manufacture web site for your device for additional information.

The setup process differs for Windows and macOS, and is explained in detail on the Android developer website. For more information on connecting your Android device to the SDK, refer to the Running Your App section of the Android Developer documentation.

Go to Settings > Developer options, and check the USB debugging checkbox to enable debug mode when the device is connected to a computer via USB.

Android5.0 (Lollipop) で表示された開発者向けオプション -Samsung Galaxy Note 3
Android5.0 (Lollipop) で表示された開発者向けオプション -Samsung Galaxy Note 3

4. Configure the Android SDK path in Unity

The first time you create a Project for Android (or if Unity later fails to locate the SDK), Unity asks you to locate the folder in which you installed the Android SDK.

If you installed the SDK using the sdkmanager, you can find the folder in <android tools install location>\platforms\<android sdk folder>.


c:\<android tools install location>\platforms\android–27

If you installed the SDK when you installed Android Studio, you can find the location in the Android Studio SDK Manager. To open the SDK Manager from Android Studio, click Tools > Android > SDK Manager or click SDK Manager in the toolbar.

SDK Manager toolbar button
SDK Manager toolbar button

To change the location of the Android SDK, in the menu bar go to Unity > Preferences > External Tools.

5. Download and set up the Android NDK

If you are using the IL2CPP scripting backend for Android, you need the Android Native Development Kit (NDK). It contains the toolchains (such as compiler and linker) needed to build the necessary libraries, and finally produce the output package (APK). If you are not targeting the IL2CPP back end, you can skip this step.

NDK Downloads web ページから Android NDK version r13b (64-bit) をダウンロードします。android-ndk フォルダーをコンピューターのディレクトリに取り出し、場所を記録します。

初めて IL2CPP を使って Android のプロジェクトをビルドするときは、そのフォルダーを Android NDK をインストールしたフォルダーに置くよう指示されます。NDK のインストールを行ったルートフォルダーを選択してください。Android NDK の場所を変更するには、Unity エディターで Unity > Preferences に移動し Unity Preferences ダイアログボックスを表示します。ここで External Tools をクリックします。

Android での開発を始める
Unity Remote