This tutorial describes how to use Arm Graphics Analyzer to capture a graphics trace of a debuggable application running on an Android device with a Mali GPU.

Choose Next to browse through the steps as you work through them, or choose Single Page to view all the steps on one page.

Before you begin

On your host machine:

  1. Download and install the Arm Mobile Studio package appropriate to your host platform (Windows, Linux, or macOS).
  2. Install Android Debug Bridge (ADB). ADB is available with the Android SDK platform tools.
  3. Edit your PATH environment variable to add the path to the Android SDK platform tools directory.
    You can also set the path to Android Debug Bridge in Graphics Analyzer. Select Edit > Preferences and select Browse in the Path to ADB field to locate the adb executable.

Configure your device

  1. Ensure Developer Mode is enabled, then enable USB Debugging using Settings > Developer options.
  2. Connect the device to your host machine. To test the connection, run the adb devices command in a terminal window on the host, which should return the ID of your device.
    adb devices
    List of devices attached
    ce12345abcdf1a1234       device

    If adb devices does not work, check that you have installed Android Debug Bridge correctly, see Before you begin.

  3. The device must be able to use TCP/IP on port 5002 to communicate with the host. Make sure that this port is not in use.
  4. The application you want to trace must be debuggable. For example, in Unity applications, select the Development Build checkbox in the Build Settings when you build your application.

Prepare your application

If you're using Unity or Unreal Engine to build your application, follow the instructions here instead:

To enable Graphics Analyzer to perform a trace on devices running Android 9 or earlier, you need to add the Arm interceptor library to your application. Graphics Analyzer uses this library to collect information about the graphics API calls made by your application.

Note: This step is only necessary for devices running Android 9 or earlier. For Android 10 devices Graphics Analyzer can use GLES layers or Vulkan validation layers to collect information from the device. You can ignore this step and go straight to Capture a trace.

  1. Specify the location of the interceptor library, libAGA.so, in the module’s build.gradle file by adding the following line to the SourceSet main:
     jniLibs.srcDirs += ['<install_dir>/graphics_analyzer/target/android/arm/unrooted/']
    For example:
    sourceSets {
    main {
    manifest.srcFile 'AndroidManifest.xml'
    resources.srcDirs = ['res']
    res.srcDirs = ['res']
    assets.srcDirs = ['assets']
    java.srcDirs = ['src']
    jniLibs.srcDirs += ['/Applications/Arm_Mobile_Studio_2020.0/graphics_analyzer/target/android/arm/unrooted/']
    Note: Specify the unrooted directory, not the subdirectory that contains the library.
  2. Ensure that the abiFilters property in the module’s build.gradle file is set to a value that the interceptor supports; either armeabi-v7a, arm64-v8a, or both. For example:
    android {
    compileSdkVersion 28
    buildToolsVersion "28.0.3"

    defaultConfig {
    minSdkVersion 9
    targetSdkVersion 28

    ndk {
    abiFilters 'armeabi-v7a', 'arm64-v8a'
  3. Enable the interceptor by adding a Java component to the application to be traced to enable it to load the interceptor library. The details of this step depend on the type of application.

    For applications that use C or C++ only:
    1. Create a new Activity class that extends android.app.NativeActivity.
    2. Reference this new Activity in your AndroidManifest.xml as the android:name attribute of the activity element.
    3. Ensure that the android:hasCode attribute of the application element is set to true, otherwise the Java file will not be included in the APK.
    For applications that use Java, C/C++, or both, add the following code to the beginning of the project's main Activity class:
          catch (UnsatisfiedLinkError e)
          {            // Feel free to remove this log message.
               Log.e("[GA]", "GA not loaded: " + e.getMessage());
               Log.d("[GA]", Log.getStackTraceString(e));
    Note: For more information about this step, see the Target installation section of the Graphics Analyzer User Guide.
  4. Recompile the application and install it on the target device.

Prepare your Unity application

If your application is built using Unity, follow these steps to prepare your application for tracing:

Check your SDK and NDK versions

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.

Add the interceptor library to your project

To enable Graphics Analyzer to trace your application on devices running Android 9 or earlier, you need to add the Arm interceptor library to your Unity project. The interceptor library intercepts and collects information about the OpenGL ES and EGL function calls made by the application. Unity detects the presence of the interceptor 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.

Note: This step is only necessary for devices running Android 9 or earlier. For devices running Android 10, you can ignore this step, because Graphics Analyzer uses GLES layers or Vulkan validation layers to collect information from the device instead.


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


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. 

  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.

Player and build settings

Set the following in Unity to build a debuggable application that Graphics Analyzer can trace.

  1. Select File > Build Settings, then select Player Settings.
  2. Under Identification, set Target API Level to the required Android version.

    Note: 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.

  3. 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.

  4. 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.
  5. 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

Prepare your Unreal Engine application

Note: This step is only necessary for devices running Android 9 or earlier. For Android 10 devices Graphics Analyzer can use GLES layers or Vulkan validation layers to collect information from the device. You can ignore this step and go straight to Capture a trace.

To enable Graphics Analyzer to trace your application, you need to enable Graphics Analyzer in your Unreal Engine project:

  1. Open your Unreal Engine project.
  2. Open the Project Settings window.
  3. Under Platforms, select Android.
  4. On the right-hand side, under Graphics Debugger, select Mali Graphics Debugger from the Android Graphics Debugger drop-down list.
    Note: Mali Graphics Debugger is the old name for Graphics Analyzer.
  5. In the Mali Graphics Debugger Path field, enter the path to the Graphics Analyzer folder in the Arm Mobile Studio installation directory:

Capture a trace

Connect to your device and start the capture in Graphics Analyzer.

  1. Launch Graphics Analyzer:
    1. On Windows, open the Windows Start menu, navigate to the Arm Mobile Studio folder, and select the Graphics Analyzer shortcut.
    2. On macOS, use Spotlight to search for Graphics Analyzer or go to the <install_directory>/graphics_analyzer/gui folder, and double-click the Graphics Analyzer.app file.
    3. On Linux, navigate to the location where you extracted the package, go to the graphics_analyzer/gui directory, and run the aga file.
      cd <install_directory>/graphics_analyzer/gui
  2. Select Open the Device Manager from the Debug menu.
    1. Select your connected device from the list of Android devices.
    2. Select the application you want to debug
    3. Select Trace Activity.
    Graphics Analyzer Device Manager
    Graphics Analyzer connects to your device and installs the layer driver and daemon application that it uses to communicate with it.
  3. Optionally, select Trace Config and select which API assets are captured. Only enable the asset types you need. The more asset types you enable, the slower the application will run, the more memory is required, and the generated trace file will be larger.
    Graphics Analyzer Trace Configuration
  4. Perform your test scenario on the device. Graphics Analyzer displays the trace data as it receives it from the device.
  5. When you get to a problem area, use the pause, step and play buttons to locate a frame that you want to analyze more closely:
    Graphics Analyzer buttons
  6. Click the camera icon Graphics Analyzer frame capture button to capture the frame buffer output at the current frame.
  7. Optionally, capture extra frame data by enabling the following modes:
    1. Overdraw Graphics Analyzer overdraw button
    2. Shader map Graphics Analyzer shader map icon
    3. Fragment count Graphics Analyzer fragment count button
    Enable the mode, then click the camera icon Graphics Analyzer frame capture button to collect the data.
  8. To stop tracing, click Stop tracing icon.
    All the frames are listed in the Trace Outline view. The frames where you've captured extra data are shown with an icon, to identify the type of frame capture you performed.
  9. To filter the frames to just those where you've captured extra data, use the Show Only Frames With Features Enabled option
    Filtering the trace outline in Graphics Analyzer
  10. Expand a frame to see the renderpasses and draw calls within it. 
    Expanding frames in Graphics Analyzer
  11. Select frames, renderpasses and draw calls to explore their data. Refer to the Graphics Analyzer user guide information about the different data views.
  12. Save or export the trace file, using options under the File menu.