- Android SDK/NDK setup
- 1. Download the Android SDK
- 2. Install the Android SDK
- 3. Enable USB debugging on your device
- 4. Connect your Android device to the SDK
- 5. Configure the Android SDK path in Unity
- 6. Download and set up the Android NDK
- Android environment setup
- 1. Install Android Build Support and the Android SDK & NDK tools
- 2. Enable USB debugging on your device
- ADB debugging for Chrome OS devices
- Connecting to your Chrome OS device
- Customizing the Android SDK & NDK Tools and OpenJDK installation
- Change the OpenJDK path
- Change the Android SDK Tools path
- Change the Android NDK path
- Updating the Android SDK Target API
- Installing the Android Development Tools
- Installing the JDK/SDK/NDK
- Handling an Android SDK Manager Issue on Windows 8
- Configuring RAD Studio to Work with Your Installed SDK
- Adding Java as a User Override to Your System Path
Android SDK/NDK setup
Whether you’re building an Android application in Unity or programming it from scratch, you need to set up the Android Software Development Kit (SDK) before you can build and run any code on your Android device.
1. Download the Android SDK
Download the Android SDK from the Android Studio and SDK Tools download page. You can either use an Android Studio and SDK bundle, or only download the SDK command line tools.
2. Install the Android SDK
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.
3. Enable USB debugging on your device
To enable USB debugging, you need to enable Developer options. 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 different devices and Android versions, refer to your hardware manufacturer.
Build number as displayed in Android 5.0 (Lollipop) on a Samsung Galaxy Note 3
Note: On operating systems older than Android 4.2 (Jelly Bean), the Developer options aren’t hidden. Go to Settings > Developer options, then enable USB debugging.
After you have navigated 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. 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.
Developer options as displayed in Android 5.0 (Lollipop) — Samsung Galaxy Note 3
4. Connect your Android device to the SDK
Connect your Android device to your computer using a USB cable. If you are developing on a Windows computer, you need to install the appropriate USB driver for your device.
For more information on connecting your Android device to the SDK, refer to the Running Your App section of the Android Developer documentation.
5. Configure the Android SDK path in Unity
The first time you make a Project for Android (or if Unity later fails to locate the SDK), you will be asked to locate the folder where you installed the Android SDK. Select the root folder of your SDK installation. If you wish to change the location of the Android SDK, in the menu bar go to Unity > Preferences > External Tools.
6. Download and set up the Android NDK
If you are using the IL2CPP scripting back end 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.
Download the Android NDK version required by Unity from the NDK Downloads web page, and then extract it to a directory. The first time you build a project for Android using IL2CPP, you will be asked to locate the folder where you installed the Android NDK. Select the root folder of your NDK installation. If you wish to change the location of the Android NDK, in the Unity Editor, navigate to menu: Unity > Preferences… to display the Unity Preferences dialog box. Here, click External Tools.
Источник
Android environment setup
To build and run for Android, you must install the Unity Android Build Support platform module. You also need to install the Android Software Development Kit (SDK) and the Native Development Kit (NDK) to build and run any code on your Android device. By default, Unity installs a Java Development Kit based on OpenJDK.
Note: Unity supports Android 4.4 “KitKat” and above. See AndroidSdkVersions for details.
1. Install Android Build Support and the Android SDK & NDK tools
Use the Unity Hub to install Android Build Support and the required dependencies
See in Glossary : Android SDK & NDK tools, and OpenJDK.
Add Android modules
You can install Android Build Support, the Android SDK & NDK tools and OpenJDK when you install the Unity Editor, or add them at a later time.
For information on adding the Android modules:
If you are using a 2018 version of Unity, see the Unity 2018.4 documentation for information on manually installing these dependencies.
2. Enable USB debugging on your device
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; for stock Android, it’s usually Settings > About phone > Build number. For specific information on your device and Android version, refer to your hardware manufacturer.
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.
Note: On Android versions prior to 4.2 (Jelly Bean), the Developer options are enabled by default.
Go to Settings > Developer options (or, if this does not work, on some devices the path is Settings > System > Developer options), and check the USB debugging checkbox. Android now enters debug mode when it is connected to a computer via USB.
Connect your device to your computer using a USB cable. If you are developing on a Windows computer, you might need to install a device-specific USB driver. See the manufacturer website 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 Run Your App section of the Android Developer documentation.
ADB debugging for Chrome OS devices
For information on how to set up your development environment for Chrome OS devices, and enable ADB An Android Debug Bridge (ADB). You can use an ADB to deploy an Android package (APK) manually after building. More info
See in Glossary debugging, see Google’s documentation on Chrome OS Developer Environments.
Connecting to your Chrome OS device
Before you can deploy to your device you need to manually connect with ADB via the device’s IP address.
To begin you need the IP address. Open up the Settings app and choose Network in the sidebar. Next click on the active network interface.
If the interface is wireless then next choose the SSID that you are connected to. In the details you will see your IP address. Make a note of it.
If you are using a wired connection your IP address will be shown on the first details page.
Now we are ready to connect. For the sake of this example let’s say that the device’s IP is 192.168.0.100. In a shell or terminal run the following command
adb connect 192.168.0.100
If the connection was successful you will see a message such as connected to 192.168.0.65:5555 . And adb devices should verify that the device is connected. List of devices attached 192.168.0.65:5555 device
From now on you may run ADB commands to target the device just as you would over a USB connection.
Note: If your device or host machine goes to sleep or loses network connectivity you may need to reconnect.
Customizing the Android SDK & NDK Tools and OpenJDK installation
Unity recommends that you use the Unity Hub to install Android SDK & NDK tools, to ensure that you receive the correct versions and configuration. Unity installs Android SDK & NDK Tools and OpenJDK respectively in the SDK, NDK and OpenJDK folders under /Unity/Hub/Editor/[EditorVersion]/Editor/Data/PlaybackEngines/AndroidPlayer/.
If you have multiple versions of Unity with the same required dependencies (be sure to check System requirements for the latest) and you want to avoid duplicating the installation of Android SDK & NDK Tools and OpenJDK, you can specify a shared location in the Unity Preferences window. To do this, go to Preferences > External tools and enter the directory paths in the SDK and NDK fields:
Preferences window showing external tools settings for Android
Warning: Unity does not officially support versions of the OpenJDK, SDK, or NDK other than the ones it supplies.
To change the OpenJDK, SDK Tools, or NDK that Unity uses to build Android apps:
- Open the Project.
- Open the Preferences window (Windows and Linux: Edit >Preferences; macOS: Unity >Preferences).
- In the left navigation column, select External Tools.
Change the OpenJDK path
- Uncheck JDK Installed with Unity (recommended).
- In the JDK field, enter the path to the JDK installation folder, or use the Browse button to locate it.
Change the Android SDK Tools path
- Uncheck Android SDK Tools Installed with Unity (recommended).
- In the SDK field, enter the path to the SDK installation folder, or use the Browse button to locate it.
Unity works with the most recent version of the Android SDK available at the time of the Unity version release.
Change the Android NDK path
- Uncheck Android NDK Installed with Unity (recommended).
- In the NDK field, enter the path to the NDK installation folder, or use the Browse button to locate it.
Each version of Unity requires a specific version of the Android NDK to be installed:
Unity version | NDK version |
---|---|
2018.4 LTS | r16b |
2019.4 LTS | r19 |
2020.3 LTS | r19 |
See the System requirements page for a complete list of requirements.
Updating the Android SDK Target API
Unity Hub installs the latest version of the Android SDK Target API required by Google Play.
If you need to use a more recent version, you can change the Target API from the Target API Level field in the Player Settings window (menu: Edit > Project Settings > Player, then select the Android platform). You can find the Target API Level option in the Other Settings > Identification section.
Selecting a target API for the Android SDK
After you select an option other than the default, Unity prompts you to update the Android SDK API. You can choose to either:
- Update the Android SDK
- Continue to use the highest installed version of the Android SDK
Note: If you select an older version of the Target API, the Unity Android SDK Updater will not be able to perform the update and will give you this message:
Android SDK does not include your Target SDK of (version). Please use the Android SDK Manager to install your target SDK version. Restart Unity after SDK installation for the changes to take effect.
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 chose, make sure to select the correct Android SDK folder for Unity in the Edit > Preferences > External Tools window.
On Windows, if the Unity Editor is installed in the default folder ( /Program Files/ ), you must run the sdkmanager with elevated privilege (Run as Administrator) to perform the update.
Источник
Installing the Android Development Tools
Important: You do not need to install the Android tools yourself.
- The installer for RAD Studio installs the current recommended and tested versions of the Android development tools during the RAD Studio product installation.
- The Android development tools are conveniently accessible using Start > All Programs > Embarcadero RAD Studio > Android Tools, as shown here:
- The Android Tools menu item opens the Android SDK Manager, from which you can start the Android Virtual Device Manager.
- The installer gives you the option to not install the Android SDK and NDK. If you opt out in the installer, you can either:
- Use a previously installed Android SDK and NDK.
- Install the Android development tools yourself, following the steps in this topic.
Be aware that you need to use the recommended versions of the Android development tools; alternate versions might introduce changes that cannot be supported by RAD Studio. Note: The JDK is installed if you do not have the recommended version of Java (1.6 or 1.7), regardless of whether the Android development tools are installed for you during product installation.
Having the Android development tools installed on your development system is required for developing Android apps using RAD Studio. To build mobile apps for the Android target platform, you also need to add an Android SDK to the RAD Studio SDK Manager.
Here are the default installed locations of the Android development tools as installed by the RAD Studio installer:
- Java Development Kit (JDK): C:\Program Files\Java\jdk1.7.0_25
- Android Software Development Kit (SDK): C:\Users\Public\Documents\RAD Studio\12.0\PlatformSDKs\adt-bundle-windows-x86-20130522\sdk
- Android Native Development Kit (NDK): C:\Users\Public\Documents\RAD Studio\12.0\PlatformSDKs\android-ndk-r8e
Installing the JDK/SDK/NDK
- Install the JDK (Java development kit):
- On the PC, download and run the JDK installer, which is available here: http://www.oracle.com/technetwork/java/javase/downloads/index.html
- Install the Android SDK (software development kit):
- In your browser on the PC, open the Android SDK download page and click Download the SDK Tools ADT Bundle for Windows.
- On the Get the Android SDK page, you can select either 32-bit or 64-bit, according to your Windows platform.
- This download includes the SDK tools and the Eclipse IDE. After the download completes, you can safely delete the SDK\adt-bundle-windows-x86_64-20130522\eclipse folder, unless you want to use the Eclipse IDE.
- From your directory, run SDK Manager.exe. Tips: If the Android SDK Manager does not start, try these suggestions:
- Right-click SDK Manager.exe and choose Run As Administrator.
- Run android.bat from the \tools directory inside your directory.
- In the Android SDK Manager tree, check (enable) the following nodes:
- Tools node
- SDK Platform node within the Android (API ) node, where must be 9 or a higher value (for example, «18»). Note: RAD Studio supports Android 2.3 and later versions regardless of which SDK Platform you download. Android SDK platforms are backward compatible.
- Click Install packages, click Accept License to accept the required licenses, and click Install to install the required software.
- You can close the Android SDK Manager when the installation finishes.
- In your browser on the PC, open the Android SDK download page and click Download the SDK Tools ADT Bundle for Windows.
- Install the Android NDK (native development kit):
- On the PC, download and unzip the NDK for your Windows version (32-bit or 64-bit), available here: http://developer.android.com/tools/sdk/ndk/index.html.
After installing these tools, you need to add an Android SDK to RAD Studio, as described in the next section, and then you can start building mobile applications for the Android platform.
Handling an Android SDK Manager Issue on Windows 8
On Windows 8, you might see errors when you start the Android SDK Manager. If this happens, you might not be able to download any additional SDKs.
The solution is to edit the android.bat file and change the line that launches the Android SDK Manager. Add -Djava.net.preferIPv4Stack=true to the call to Java, as follows:
call %java_exe% -Djava.net.preferIPv4Stack=true %REMOTE_DEBUG% -Dcom.android.sdkmanager.toolsdir=»%tools_dir%» -Dcom.android.sdkmanager.workdir=%work_dir% -classpath «%jar_path%;%swt_path%\swt.jar» com.android.sdkmanager.Main %*
This issue seems to be related to Windows 8 wanting to use Internet Protocol V6.
Configuring RAD Studio to Work with Your Installed SDK
You can use specific versions of the Android SDK simply by pointing the RAD Studio SDK Manager to your installed location.
- Open the Create a New Android SDK wizard by using either Tools Options or Project Manager:
- Choose Tools > Options > Environment Options >SDK Manager | Add | Add new.
- In the Project Manager:
- Right-click the Android target platform and select Properties from the context menu.
- In the SDK field on the Platform Properties dialog box, click Add new in the dropdown list.
- On the Add a New SDK dialog, click Add new in the dropdown list.
- In the Android SDK Base Path and the Android NDK Base Path fields, browse to and select your installed and locations, respectively.
- The Create a new Android SDK wizard now populates the rest of the fields here and on the Android tools locations page. Allow a moment for this process to complete.
- For any fields that are not auto-populated or are marked with
, click the entry field and browse to the installed location of that library on your system.
Adding Java as a User Override to Your System Path
If you installed the JDK yourself, Java might not be in your system path. For example, if Java is not in your system path, you must use android.bat to start the Android SDK Manager (instead of SDK Manager.exe). If you want to optimize for Android development, you should add Java to your system path environment variable.
- Choose Tools > Options > Environment Options >Environment Variables .
- In the System variables pane, double-click the Path item.
- In the Override System Variable dialog box, click the Home button on your keyboard to bring the focus to the beginning of the path.
- Add the path to Java at the beginning of your system path (it must precede all references to System32). For example, the default installed path to java.exe in RAD Studio is: C:\Program Files\Java\jdk1.7.0_25\bin Note that you should only need to add an override if your Java installation is different from this. End your path entry with a semicolon (;):
- Click OK on the Override dialog box, and click Yes on the Confirm dialog box that follows.
- Verify that you see the path to Java shown at the start of the Path field in the User overrides pane:
- Click OK to close the Tools Options Dialog Box.
Источник