Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Debugging Android IL2CPP builds

Discussion in 'Android' started by sebas86, Sep 5, 2017.

  1. sebas86

    sebas86

    Joined:
    Jul 1, 2013
    Posts:
    7
    Unity Team, did you plan update documentation with info about debugging Android IL2CPP builds?

    Background: I have problem with strange freezes only in Android IL2CPP builds. It looks like Unity from time to time generate build which hang in this same place over and over, when making new build without changing anything in code or project settings generate perfectly fine build… But I'm not sure if it's my fault or some strange bug in IL2CPP compiler.

    Before freeze application doesn't generate any error message, just stops react to any touch or even screen rotation event.

    Is there any chance to attach debugger (ndk-gdb?) to Unity build and get native stack traces to figure out where freezes/errors occur? On iOS I can use Xcode integrated debugger but with Android I have no idea how to debug IL2CPP applications. Sadly I can't reproduce this bug with IL2CPP iOS or Android Mono versions.
     
    yuliyF likes this.
  2. sebas86

    sebas86

    Joined:
    Jul 1, 2013
    Posts:
    7
    How to debug Android IL2CPP builds:

    1. Export project with Gradle build system.
    2. Import project in Android Studio.
    3. Create run/debug configuration for android app with debug type (debugger tab) set to native.
    4. Run build.

    To set breakpoints use symbolic breakpoints and function/method names from generated by IL2CPP code. Project specific generated C++ code are stored in $PROJECT/Temp/StagingArea/Il2Cpp/il2cppOutput, some shared code are available in $UNITY/Contents/il2cpp/. Function and method names you can always get from generated map file (libil2cpp.map).

    Probably problems:
    1. Latest Unity 5.6.x create Gradle build script with outdated dependencies, if you get errors in build.gradle try update this line:
    dependencies {
    classpath 'com.android.tools.build:gradle:2.2.0'
    }

    to
    dependencies {
    classpath 'com.android.tools.build:gradle:2.3.3'
    }

     
    Last edited: Sep 6, 2017
    astrokoo3 likes this.
  3. Wecica

    Wecica

    Joined:
    Jul 20, 2016
    Posts:
    27
    How can I debug Android IL2CPP builds with Visual Studio? I tried to attach the debugger to an Android device, but no USB device showed in the attach list. But if I build the app with Mono, there will be no problem attaching the debugger.
     
    Last edited: Aug 15, 2019
  4. ebenknot

    ebenknot

    Joined:
    Dec 26, 2013
    Posts:
    89
    They should update documentation about this because they are becoming crazy all of us.
     
  5. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,773
    Managed code debugging should work with IL2CPP the same way it does with Mono. If not, please submit a bug report, as something is wrong. You can find the documentation here: https://docs.unity3d.com/Manual/ManagedCodeDebugging.html