I have created a JUCE based audio library in C++ (originally as a windows DLL)
I have successfully built it into an AAR library with Android Studio
I can successfully run it in a Unity3D build for Android.
I can get the debugger messages back to LogCat
However, I really need to step through some part of the native C++ code with a managed debugger. ( I know how use a debugger for the c# for unity on android)
I’ve searched for days but cannot find an answer.
Unity3D 2018.3.11f1
Android Studio 3.4.1 Build #AI-183.6156.11.34.5522156, built on May 1, 2019 JRE: 1.8.0_152-release-1343-b01 amd64 JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o Windows 10 10.0
You use Android Studio’s Native Debugger for such cases, from Unity choose Export Project in BuildPlayerWindow, and import that project in Android Studio.
Set debugger type to Native in Android Studio, in project settings set the symbol path, if those were separated from library files. And you’re good to go.
Assuming the library was built on same machine, you drag & drop C/C++ files in your Android Studio project and place breakpoints there.
P.S AAR is simply a package (a zip file), the native library sits in aar itself, which has .so extension. You can actually unzip AAR using 7zip or othere compression program.
OK, I built the AAR. (I know it a zip too - but a good tip!)
So I just need to copy the source files into the exported project into the /libs folder? sorry if this seems obvious, just a complete android nube except for vanilla builds.
You don’t need to copy them, you simply need to open them in Android Studio, either drag & drop, or File->Open, after that you can start placing breakpoints
I’ve done that, but it doesn’t hit the breakpoint I set - although I know from the logcat that it must have past that point (a Debug.Log() command from unity to the native code prints successfully)
EDIT: my error, I was setting the wrong path for the symbols.
@garrilla amazing you got this working! Could you share what the path to your symbols was? I seem to have the same setup as you describe. I want to attach the native debugger to my native DLL in my Unity project running on Android. I’m unsure where to point it to for symbols.
why did you do this? src\main\jniLibs\armeabi-v7a\ should contain executable code only, don’t copy symbol file on top of it. You need to rename ibil2cpp.so.debug to ibil2cpp.so but keep where it is, and tell Android Studio where to look for it.
Android: When exporting a gradle proejct, il2cpp generated native files will be also copied to gradle project, the il2cpp library will be compiled/linked via gradle. Previously il2cpp library was being precompiled/prelinked by Unity when exporting project. This improvement gives you an ability to both debug and profile il2cpp files when needed, it also increases your control over the build pipeline. Note: If you don't export a project, il2cpp library will be linked by Unity as it was before.
You’ll still need to set symbol path after project export.
but we are in live service using 2018.4.10f version for 1 year
so i’m afraid to update to 2010 version
at this time. i didn’t touch the directories. and specify symbol directories outside android studio where ilil2cpp.so.debug file exist
and change il2cpp.so.debug to il2cpp.so
run this setup has same result
‘image list’ not showing libil2cpp.so and libmain.so, libunity.so
Can you clarify? Unity doesn’t support x86, it only supports ARMv7 and ARM64. So is this a typo what you wrote? (Edit: sorry, forgot that 2018 still let’s you select x86)
Also just in case, you’re testing on physical device, not an emulator? Because lldb won’t work on emulator with Unity apps.