Build for Android

Open the sample project (if you haven’t already) and open the SampleScene as per the previous section.

We’re going to build the sample for Android. To do so takes just a few steps and they are all achieved from the Build Settings window.

  1. First off, we need to switch the project to Android.

  2. Select File->Build Settings to show the Build Settings window:

    Image Alt Text:Build Settings windowFigure 1. Build Settings window

  3. Notice how the project is currently in “Windows, Mac, Linux” mode. We need to switch to Android.

  4. Select Android on the left and then click on Switch Platform. This will take a few moments as it re-builds the assets for the Android mode (this step can take longer the first time it is done for any project).

    Image Alt Text:Switch platform to AndroidFigure 2. Switch platform to Android

  5. We must now tell Unity which scene to open when the app runs. This affects all platforms. Click on Add Open Scenes to add the opened sample scene to the Scenes in Build list. We will only need to do this once.

Image Alt Text:Scenes in BuildFigure 3. Scenes in Build list

That’s all we need to do to simply run the app. There are a couple more steps required to run the profiler but we’ll cover those later.

Prepare your Android device for development

To deploy to your Android device, we will need to enable the Android Developer Options and USB Debugging on your device:

  1. Go to your Android settings app

  2. Scroll to the bottom to find Developer Options. If you do not see this option, follow the instructions for configuring developer options .

  3. In Developer Options ensure the On option is enabled.

  4. Scroll down to find and enable USB Debugging.

Deploy to your Android device

Connect your Android device to your computer using a USB cable. Unity may take a few moments to recognize it.

Android may ask for confirmation before enabling the connection.

In the Build Settings window:

  1. Ensure your device appears in the Run Device menu and select it.

  2. Select Build and Run. Choose a location to save your build.

  3. The project will now build for Android and deploy to your device.

You will see the spinning cube running slowly. On recent Android devices, we would definitely expect it to run more quickly (at 60 frames per second).

We’re now ready to dive into the Unity Profiler.

Back
Next