[JAVA] How to use Mali Graphics Debugger to debug apps for Android (even those made with + Unity)

Mali Graphics Debugger There is a debugger for Android devices that uses Mali for the GPU called "Mali Graphics Debugger".

This time, I learned how to use this debugger, so I summarized it. The second half also touches on how to use Unity-created apps.

procedure

This time, I did it for the 32-bit version (armeabi-v7a) on an Android device that is not rooted. By the way, the one I used is the Galaxy S6.

1. Download

First, download the Mali Graphics Debugger from the ARM Site (http://malideveloper.arm.com/resources/tools/mali-graphics-debugger/). Execute the downloaded file and install the necessary files. You can leave the default installation destination.

2. Move the libMGD.so file

Of the folder you downloaded earlier 'C:\Program Files\ARM\Mali Developer Tools\Mali Graphics Debugger v4.1.0\target\android-non-root\arm\armeabi-v7a' I think there is a file called libMGD.so in it. This file 'C:\android\arm\armeabi-v7a' Move to the folder called.

3. Port forwarding

Launch Android Studio and open the file of the app you want to debug. Connect your Android device to your PC and enter the following command at the Android Studio command line.

adb forward tcp:5002 tcp:5002

4. Install daemon program on Android device

Install the daemon program on the Android device side. Enter the following command on the command line.

adb install -r C:\Program Files\ARM\Mali Developer Tools\Mali Graphics Debugger v4.1.0\target\android-non-root\MGDDaemon.apk

5. Edit build.gradle

Add the following jniLibs dir to your app's build.gradle

build.gradle


sourceSets.main.jniLibs.srcDir 'C:\\Android\\arm'

\ May have to be changed to a yen mark

6. Edit MainActivity

Add the following code to the main activity of the app.

MainActivity.java


static {
    	try {
        		System.loadLibrary("MGD");
    	}
    	catch( UnsatisfiedLinkError e ){
        		// Feel free to remove this log message.
        		Log.e("[ MGD ]", "libMGD.so not loaded.");
    	}
}

7. Run the app

Install the app on your Android device. Then open the target app from the MGD Daemon app.

8. Launch the debugger

On the PC 'C:\Program Files\ARM\Mali Developer Tools\Mali Graphics Debugger v4.1.0' Please start Launch.bat in. After startup, select Connect to target from Debug in the upper left menu to start tracing.

For Unity

In the case of an app created with Unity, it worked fine when I ran it according to this person's site.

Building a Unity Application with Mali Graphics Debugger Support

If you can read English, I think that you can execute it without any problem if you read this site. It's okay to do what is written here instead of step 6 above.

I will summarize only what I needed in Japanese.

1. Create a StandardActivity class

Do not perform step 6 above. Instead, create a new StandardActivity.java class and write the following code.

StandardActivity.java


package test.application;  
import com.unity3d.player.UnityPlayerActivity;  
import android.os.Bundle;  
import android.util.Log;  
  
public class StandardActivity extends UnityPlayerActivity  
{  
    protected void onCreate(Bundle savedInstanceState)  
    {      
        try  
        {  
            System.loadLibrary("MGD");  
        }  
        catch( UnsatisfiedLinkError e)  
        {  
            Log.i("[ MGD ]", "libMGD.so not loaded.");  
        }  
        super.onCreate(savedInstanceState);  
    }  
}  

2. Editing Android Manifest

Rewrite android: name of activity in AndroidManifest.xml.

AndroidManifest.xml


activity android:name=”StandardActivity” 

After that, you can debug by following the above procedure.

Recommended Posts

How to use Mali Graphics Debugger to debug apps for Android (even those made with + Unity)
[For those who create portfolios] How to use binding.pry with Docker
How to use nginx-ingress-controller with Docker for Mac
How to use Truth (assertion library for Java / Android)
[For those who create portfolios] How to use font-awesome-rails
[For those who create portfolios] How to use chart kick
How to fix Android apps crashing with RenderThread mystery error
How to use mssql-tools with alpine
How to use binding.pry for view files
[Android] How to deal with dark themes
[Rails] How to use rails console with docker
[Ruby] How to use slice for beginners
[For beginners] How to debug in Eclipse
How to use ExpandableListView in Android Studio
[Java] How to test for null with JUnit
How to use MyBatis2 (iBatis) with Spring Boot 1.4 (Spring 4)
How to use an array for HashMap keys
How to use Java framework with AWS Lambda! ??
How to use Java API with lambda expression
How to make Unity Native Plugin (Android version)
How to use nfs protocol version 2 with ubuntu 18.04
[Rails] How to use Gem'rails-i18n' for Japanese support
How to use docker compose with NVIDIA Jetson
[For super beginners] How to use autofocus: true
How to use UsageStatsManager in Android Studio (How to check the startup time of other apps)
`bind': Address already in use --bind (2) for 127.0.0.1:3000 (Errno :: EADDRINUSE) How to deal with the error