Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - debug native code of AAR library

I have the following situation. Due to some requirements I've to extract some parts of our app into a separate AAR library. So it looks like that:

  • Native C++ code together with some Java wrappers is compiled into an AAR library
  • The library is then added as a library module in the main app

  • The compilation itself is configured with Gradle + CMake

Everything works as expected but I've one problem, I cannot debug the native C++ part anymore. Both modules are compiled in DEBUG. It also doesn't help to set the LLDB symbol directory (to LIB_PATH/.externalNativeBuild/cmake/debug/ABI_XXX/CMakeFiles/native-lib.dir/). Setting the LLDB debug type doesn't seem to help either.

When I put my library code back into the main app I can debug everything without a problem.

Is it simply not possible to debug the native part of an AAR library? Or can anyone tell me what I'm doing wrong?

like image 398
Christoph Avatar asked May 05 '17 13:05

Christoph


People also ask

How do I debug an AAR file?

While debugging when it prompt “Choose Sources”, Click on that option and select the “main” folder of the library module from your local codebase of the library. Now try to debug (by choosing 'step into' option etc), the debugger should able to get the source code.

How do I use .AAR files on Android?

Add your AAR or JAR as a dependency To use your Android library's code in another app module, proceed as follows: Navigate to File > Project Structure > Dependencies. In the Declared Dependencies tab, click and select Jar Dependency in the dropdown. In the Add Jar/Aar Dependency dialog, first enter the path to your .

What is the difference between AAR and jar?

An AAR is similar to a JAR file, but it can contain resources as well as compiled byte-code. AAR files can contain Android resources and a manifest file, which allows you to bundle in shared resources like layouts and drawables in addition to Java classes and methods.


1 Answers

For some reason I found this blog entry only now... http://www.akaita.com/post/android-native-library-module-debug/

Although the author is using the experimental ndk plugin I can confirm that it's also working with the stable gradle version + CMake!

like image 195
Christoph Avatar answered Oct 01 '22 13:10

Christoph