- Android SDK 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. Add the Android SDK path to Unity
- Настройка Android SDK
- 1. Скачать Android SDK
- 2. Установить Android SDK
- 3. Удостовериться, что система определяет ваше устройство
- 4. Добавить путь до Android SDK в Unity
- Android environment setup
- 1. Download the Android SDK
- 1a. Install the Android SDK using the command line tools
- 1b. Install the SDK using Android Studio
- 2. Enable USB debugging on your device
- 3. Configure the Android SDK path in Unity
- 4. Download and set up the Android NDK
- Using an alternate Java Development Kit
- Terresquall Blog
- Recent Posts
- Terresquall Blog
- 1. Manually setting Android file paths
- 2. Installing Google USB Driver
- a. Direct installation
- b. Through Android Studio’s SDK Manager
- 3. Setting your target platform in Build Settings
- 4. Setting your target platform on Unity Hub
- 5. Using Android Debug Bridge (adb)
- 6. Enabling other Developer Options
- 7. SDK, NDK or JDK installation issues
- 8. Bonus: Hiding Developer Options again
- 9. Afterword
Android SDK Setup
Whether you’re building an Android application in Unity or programming it from scratch, you need to set up the Android SDK (software development kit) before you can build and run any code on your Android device.
1. Download the Android SDK
On your PC, go to the Android Developer SDK website. Download and unpack the latest Android SDK.
2. Install the Android SDK
Follow the instructions in Installing the SDK. You can skip the optional sections relating to Eclipse. In step 4 of Installing the SDK, be sure to add at least one Android platform with API level equal to or higher than 9 (Platform 2.3 or greater), the Platform Tools, and the USB drivers if you’re using Windows.
3. Enable USB debugging on your device
USB debugging is a useful way to debug while connecting your Android device to the SDK, so get this set up before moving on to the next step.
To enable USB debugging, you first need to enable Developer options. To do this, navigate your phone to the “Build number” portion in your device’s Settings. Finding it can be different depending on the device:
- Stock Android: Settings >About phone >Build number
- Samsung Galaxy S5: Settings >About device >Build number
- LG G3: Settings >About phone >Software information >Build number
- HTC One (M8): Settings >About >Software information >More >Build number
Note: On operating systems older than version 4.2 (Jelly Bean), the Developer options aren’t hidden. Go to Settings > Developer options, then enable USB debugging.
Navigate to Build number using the instructions above. Tap on the build number 7 times. A small pop-up notification appears saying “you are now X steps away from being a developer” with a number that counts down with every additional tap. On the 7th 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.
4. Connect your Android device to the SDK
This can be tricky, especially under Windows-based systems where drivers tend to be a problem. Your device may come with additional information or specific drivers from the manufacturer.
- Windows: If the Android device is automatically recognized by the system you still might need to update the drivers with the ones that came with the Android SDK. You can do this through the Windows Device Manager. If the device is not recognized automatically, use the drivers from the Android SDK, or any specific drivers provided by the manufacturer. Find further information regarding USB Drivers for Windows on the Android Developer page.
- Mac: If you’re developing on macOS, you usually don’t need any additional drivers.
If you are unsure whether your device is properly installed on your system, please read the Android development troubleshooting page for details.
5. Add the Android SDK path to Unity
The first time you build 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 the SDK installation. If you wish to change the location of the Android SDK, in the menu bar go to Unity > Preferences, then click External Tools.
Источник
Настройка Android SDK
Прежде чем вы сможете запустить написанный код на Android-устройстве, нужно выполнить несколько простых действий. Это относится как к работе с Unity, так и к созданию приложений с нуля.
1. Скачать Android SDK
Зайдите на страницу Android Developer SDK. Скачайте архив с последней версией Android SDK и распакуйте его.
2. Установить Android SDK
Следуйте инструкциям на странице Installing the SDK (причём, вы можете свободно пропустить опциональные части, относящиеся к Eclipse). В шаге 4 руководства Installing the SDK убедитесь, что добавили как минимум одну Android platform (Android платформу) с уровнем API равным или выше 9 (платформа 2.3 или выше), Platform Tools и USB drivers (USB драйверы), если вы используете Windows.
3. Удостовериться, что система определяет ваше устройство
Это может быть не так просто, особенно на Windows системах, в которых драйвера часто бывают источником проблем. Также, с вашим устройством может идти дополнительная информация или особые драйверы от производителя.
Для Windows: если Andoid устройство автоматически определяется системой, вам все равно придётся обновить драйверы на те, который поставляются с Android SDK. Это делается через диспетчер устройств Windows. —>Если устройство не определяется автоматически, используйте драйверы из Android SDK или особые драйверы, предоставленные производителем. —>Дополнительную информацию можно найти здесь: USB Drivers for Windows
Для Mac: если вы разрабатываете на OSX, тогда обычно не требуется никаких дополнительных драйверов.
Важно: Не забудьте включить “Отладку по USB” на вашем устройстве. Перейдите в Настройки -> Параметры разработчика , для включения отладки по USB. Начиная с Android Jelly Bean 4.2, параметры разработчика по умолчанию скрыты. Для их включения, понажимайте несколько раз пальцем на строку в меню Настройки -> Об устройстве -> Номер сборки . После этого вам станет доступен пункт Настройки -> Параметры разработчика .
Если вы не уверены, что ваше устройство корректно установилось в системе, пожалуйста, прочтите страницу Решение проблем при разработке под Android для дополнительной информации.
4. Добавить путь до Android SDK в Unity
При первой сборке проекта под Android (или если Unity не сможет обнаружить SDK), вас попросят указать местоположение папки, в которую вы установили Android SDK (вы должны выделить корневую папку установленного SDK). Путь до Android SDK также можно изменить в редакторе, выбрав в меню Unity > Preferences и перейдя в раздел External Tools окна настроек.
Источник
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. By default, Unity installs a Java Development Kit based on OpenJDK.
1. 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.
1a. 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:
Unzip the tools folder to a location on your hard drive.
Open a command-prompt window.
Navigate to the bin folder in the location where you unzipped the tools folder:
install folder > tools > bin
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.
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. However, there might be cases where 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
. 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”
- If you are running on Windows, install the USB device drivers:
This installs the SDK to a directory named platforms in the same directory you unzipped the tools folder to.
c: \platforms
1b. 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, 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.
2. Enable USB debugging on your device
To enable USB debugging, you must first 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 in 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, then enable USB debugging. 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 the device-specific USB driver. See the manufacture 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 Running Your App section of the Android Developer documentation.
3. 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 \platforms .
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, go to Tools > Android > SDK Manager or select SDK Manager in the toolbar.
To change the location of the Android SDK, in the Unity menu bar go to Unity > Preferences > External Tools.
4. 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 produce the output package (APK). If you are not targeting the IL2CPP backend, you can skip this step.
Download Android NDK version r16b (64-bit) from the NDK Downloads web page. Extract the android-ndk-r16b folder to a directory on your computer and note the location.
The first time you build a Project for Android using IL2CPP, Unity asks you to locate the folder in which you installed the Android NDK. Select the root folder of your NDK installation. To change the location of the Android NDK, in the Unity Editor, navigate to the menu: Unity > Preferences to display the Unity Preferences dialog box. Here, click External Tools.
Using an alternate Java Development Kit
Unity recommends that you use the JDK installed with the Android build tools, to ensure that you receive the correct version and configuration.
If you have manually installed the JDK and do not want to duplicate the installation, you can specify the location in the Unity Preferences window. To do this, go to Preferences > External tools and enter the directory path in the JDK field:
Preferences for Android external tools
Warning: The Android tools do not support JDK 9 or later; an alternate JDK must be version 8. Unity does not officially support versions of the JDK other than the one embedded in the Android Build Tools.
To change the JDK that Unity uses to build Android apps:
Open the Project.
In the left navigation column, select External Tools.
Uncheck JDK Installed with Unity (recommended).
In the JDK field enter the path to the JDK or use the Browse button to locate it.
2018–11–21 Page amended with editorial review
Источник
Terresquall Blog
If you are our Patreon, log in to enjoy an ad-free reading experience and access Patreon-exclusive articles.
Recent Posts
Terresquall Blog
This article is a continuation of our Getting Unity Remote for Android to work on Windows. If you’re here, that’s probably because you couldn’t get USB debugging to show on your Android device, and the simpler tricks we shared in our article didn’t work for you.
For ease-of-use, here are quick links to the respective sections in this article:
1. Manually setting Android file paths
24 August 2020 Update: This section was added after one of the readers from another article posted this helpful tip. It got Unity Remote working on one of my computers!
By default, if you’re using the SDK, NDK and JDK provided by Unity’s Android Build Support installation, going to Edit > Preferences > External Tools should give you the following window.
What has worked for some people (including myself), is:
- Unchecking the JDK, SDK and NDK fields (the first three checkboxes in the red box), then;
- Manually setting the paths to Unity’s JDK, SDK and NDK files.
Yes, we’re basically using the JDK, SDK and NDK files provided by Unity, but manually linking them to Unity instead of checking the checkboxes and allowing Unity to do it for us.
Once you uncheck each of the checkboxes, you should see a text field and a Browse button right beside. Clicking on each Browse button should automatically fill up the accompanying text field with the path to the Unity installed NDK, SDK and JDK respectively.
If clicking on the Browse button doesn’t work for you, you’ll have to find the files manually. They should be in either of these folders:
- C:\Program Files\Unity\Hub\Editor\[YOUR_UNITY_VERSION]\Editor\Data\PlaybackEngines\AndroidPlayer
- C:\Program Files\Unity\Editor[YOUR_UNITY_VERSION]\Editor\Data\PlaybackEngines\AndroidPlayer
The SDK and NDK are in the SDK and NDK folders respectively, but the JDK is in OpenJDK\Windows .
After this is done, you might also want to restart Unity Editor and Unity Remote, and then reconnect your mobile device, before trying again.
Article continues after the advertisement:
2. Installing Google USB Driver
For some computers, the Google USB Driver seems to be the magic component that gets Unity Remote working. There are two ways of installing the Google USB Driver:
For most modern computers, only (2) works, but you should give (1) a try first, as (2) requires installing Android Studio, which is more work.
a. Direct installation
To install the Google USB Driver on your computer, you will need to head to this page, click on the download link and accept the terms & conditions pop-up. The downloaded file is a ZIP, which you’ll need to unzip.
To make use of the unzipped files, you’ll need to connect your Android device to your computer and open the Computer Management application. If you can’t find it, click on Start and type in the app’s name to search for it.
When inside the application, select Device Manager and find your attached Android device under Portable Devices. Right-click and select Update driver.
Note: Sometimes you will find your mobile in Device Manager > Universal Serial Bus Devices instead of Portable Devices. Thanks to fibrizo for the heads up.
In the pop-up that appears, select Browse my computer for driver software on the window that pops up. Then, select the unzipped Google USB Driver folder (making sure to check Include subfolders) to install.
b. Through Android Studio’s SDK Manager
If the above steps do not work for you, you can also install Android Studio, then install Google USB Driver using its SDK Manager.
If the SDK Manager window does not show, you can click on Settings below it to access the same window. Then, do a search for SDK Manager to find the window (as pictured below). If you can’t access the window, check if the Android SDK Location (again, as pictured below) is set.
The SDK Manager looks like the image below. You’ll find the Google USB Driver under Android SDK > SDK Tools.
Article continues after the advertisement:
3. Setting your target platform in Build Settings
30 March 2021 Update: This section was added after one of the readers left this comment on the other article for Unity Remote.
For some readers, switching their build platform over to Android in File > Build Settings worked. Note that to do so, you’ll need to have Android Build Support installed on the Unity version you are using.
4. Setting your target platform on Unity Hub
19 June 2021 Update: This section was added after one of the readers left this comment on the other article for Unity Remote.
If setting your target platform on the editor’s Build Settings window didn’t work, you can try setting your project platform on Unity Hub before opening the project.
Refer to the GIF below to see where to find the dropdown.
5. Using Android Debug Bridge (adb)
In some cases, you’ll find that regardless of what you do, Unity Remote just doesn’t seem to work. In this case, it might be because your computer is unable to detect your Android device. adb.exe is a command-line tool included with Android SDKs, and it can help with that.
If you are using Unity 2019.1 and above, you don’t have to download anything to access adb.exe — it comes with Unity’s Android Build Support module, if you installed the Android SDK included with it. You should be able to find adb.exe in C:\Program Files\Unity\Hub\Editor\[YOUR_UNITY_VERSION]\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platform-tools , unless you installed Unity in a custom folder.
A possible alternative location for the file is C:\Program Files\Unity\Editor\[YOUR_UNITY_VERSION]\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platform-tools . Alternatively, you can search your drive for adb.exe to find the folder.
If you try clicking adb.exe to run it, you will find that nothing much happens. That’s because adb.exe is a command line application, which means you need to run it in Window’s Command Prompt to use it.
- To open the Command Prompt, press Windows + R on your computer to open the Run dialog. Type in cmd , and instead of pressing Enter , press Ctrl + Shift + Enter to run the program as an Administrator.
- We will need to navigate to the folder where adb.exe is in the Command Prompt before we can access the program. Type cd into the Command Prompt, followed by the path of the directory adb.exe is in, i.e. cd C:\Program Files\Unity\Hub\Editor\[YOUR_UNITY_VERSION]\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platform-tools .
Execute the adb devices command once you are in the platform-tools folder containing adb.exe . The adb devices command runs adb.exe and lists all the devices that the Android SDK is currently detecting.
If you get an output similar to the green highlighted section above, restart 1) the Unity Editor and; 2) your Unity Remote, then; 3) unplug and plugin your Android device, then try running Unity Remote again. If it still doesn’t work, try the instructions on the next paragraph.
If you don’t get an output, it means that your Android device is not being read, and this is probably what is causing Unity Remote to not work. You might want to try a different USB cable, a different USB port, or a different device altogether.
Alternatively, you can run the following on adb to restart it, and then run adb devices again.
Article continues after the advertisement:
6. Enabling other Developer Options
For some people, Unity Remote has managed to work after they’ve enabled the Stay awake option in Developer Options.
For others, it started working after they changed their USB configuration (again, in Developer Options) from MTP (Media Transfer Protocol) to PTP (Picture Transfer Protocol).
Depending on your device model, the USB configuration setting might be found in another tab instead of Developer Options.
If you can’t find the option that allows you to change your connection to PTP, take a look at this article from another site.
7. SDK, NDK or JDK installation issues
- OpenJDK installs halfway and stops without any notice. You can look at this Unity Forum topic about this issue.
- The Unity-native SDK or NDK is not compatible with the current project. If you get this, you’re just plain unlucky.
If you run into this issue, one way to go around it is to find people who have managed to get Unity Remote working on their computers and devices, or, at the very least, has a working Android Build Support module with the SDK, NDK and JDK installed.
Why? So that you can copy the SDK, NDK and / or JDK files on their Unity installation over. By the way, only copy the ones that don’t work — you probably don’t need all 3!
8. Bonus: Hiding Developer Options again
For some of you, when you’re done messing with Unity Remote, you might want to hide Developer Options again on your device. You know, what with cybersecurity being a buzzword nowadays and all.
Just head into Developer Options again, and tap the knob on the top right. This will also turn off USB debugging and set the rest of your Developer Options back to their defaults.
9. Afterword
- Find any errors in this article, or;
- Find a method that gets Unity Remote to work, that is not listed in this article;
Please leave a comment with the details! This article will be constantly updated with new findings, and you’ll be doing a public service to everyone else who is or will be going through the same battle of getting Unity Remote to work.
Article comments are below advertisement:
Источник