Unity android sdk change

Настройка 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 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.

Читайте также:  Poco x3 nfc android auto

Note: Unity supports Android 4.4 “KitKat” and above. See AndroidSdkVersions for details.

Install Android Build Support and the Android SDK & NDK tools

Use the Unity Hub to install Android Build Support and the required dependencies In the context of the Package Manager, a dependency is a specific package version (expressed in the form package_name@package_version ) that a project or another package requires in order to work. Projects and packages use the dependencies attribute in their manifests to define the set of packages they require. For projects, these are considered direct dependencies; for packages, these are indirect, or transitive, dependencies. More info
See in Glossary : Android SDK & NDK tools, and OpenJDK.

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 how to add the Android modules:

Enable USB debugging on your device

To enable USB debugging, you must enable Developer options on your device. To do this, see Android’s Configure developer options documentation.

Use a USB cable to connect your device to your computer. 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. 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

You should 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 folders under /Unity/Hub/Editor/[EditorVersion]/Editor/Data/PlaybackEngines/AndroidPlayer/ .

Читайте также:  Андроид как разблокировать микрофон

If you have multiple versions of Unity with the same required dependencies (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 your Unity 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:
    1. Disable the JDK Installed with Unity (recommended) setting.
    2. 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:
    1. Disable the Android SDK Tools Installed with Unity (recommended) setting.
    2. In the SDK field, enter the path to the SDK installation folder, or use the Browse button to locate it.

    Note: 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:
    1. Uncheck Android NDK Installed with Unity (recommended).
    2. 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:

    Unity version NDK version
    2018.4 LTS r16b
    2019.4 LTS r19
    2020.3 LTS r19
    2021.1 r21d

    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

    If you select an older version of the Target API, the Unity Android SDK Updater won’t be able to perform the update and gives 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.

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

    Источник

    Оцените статью