Prepare your Unity application

To enable report generation with Performance Advisor, you need to add the Arm interceptor library to your Unity project. Unity detects the presence of the library and automatically loads it when you build the application. Follow these steps to add the library and set Unity’s player and build settings to use it.

The library libMGD.so is provided in your Arm Mobile Studio package:

<install_directory>/performance_advisor/lwi/target/android/arm/unrooted/

Two versions of the library are provided:

  • For 64-bit applications, use the library file located in the arm64-v8a directory.
  • For 32-bit applications, use the library file located in the armeabi-v7a directory.

    Note: You can package one or both interceptor libraries depending on the requirements of your application. 

Prerequisites

Check that you are using the Unity recommended Android SDK and Android NDK versions in the Unity editor.

  • On Windows and Linux, select Edit > Preferences > External Tools.
  • On macOS, select Unity > Preferences > External Tools.

If the checkboxes are selected, they are installed. Otherwise, you can add them as modules. See https://docs.unity3d.com/Manual/android-sdksetup.html for more information.

Procedure

  1. Copy the required interceptor library, libMGD.so, into the Unity project directory Assets/Plugins/Android/, creating this directory if it does not already exist.

    If you are packaging both interceptor libraries: 
    1. Create two directories in the Assets/Plugins/ directory. For example, armv7 and armv8.
    2. Create a directory called Android in each of these directories.
    3. Copy each libMGD.so file into the appropriate Android directory.
  2. Select the library in Unity and set the following attributes in the Inspector:
    • Under Select platforms for plugin, select Android
    • Under Platform settings, set the CPU architecture to ARM64 for 64-bit applications, or ARMv7 for 32-bit applications.
    • Click Apply.
    • Unity Inspector settings for Graphics Analyzer interceptor library 
  3. Select File > Build Settings, then select Player Settings.
  4. Under Identification, set Target API Level to the required Android version.
    By default, Target API Level is set to the latest version of the Android SDK tools that you have installed. If you change to a lower API level, ensure that you have the SDK tools for that version installed, and be aware that if you want to build for a higher API version later, you will need to change this setting accordingly.
  5. Under Configuration, set the following options to build a 64-bit application:
    1. Set the scripting backend in Unity to work with 64-bit targets. SetScripting Backend to IL2CPP. For more information about IL2CPP, refer to the Unity documentation.
    2. Under Target Architectures, select ARM64.
      Unity Player Settings
      To build a 32-bit application:
      1. Leave the scripting backend at its default setting, Mono.
      2. Under Target Architectures, select ARM7.

  6. Close the Player Settings. In the Build Settings, select the Development Build checkbox. This option ensures that your application is marked as debuggable in the Android application manifest.
  7. Select Build and Run to build your APK and install it on your device in one step. Alternatively, select Build to build the APK and then install it on your device using Android Debug Bridge:
    adb install -r YourApplication.apk
Previous Next