Debugging C++/native library modules not working with Android Studio (Cmake used)

I had the same error ("Attention! No symbol directories found - please check your native debug configuration."). My solution was (Android Studio 3.2):

Run → Edit Configuration → "Debugger" tab → add your working path to Symbol Directories.

enter image description here


I had the similar issue with my own libraries some months ago because I thought that if I added the -g (gcc) flag it would generate the debug symbols, as the desktop (linux, unix kernel) apps.

But, actually it does not work to generate debug symbols.

I see that you use Cmake as a external build tool and clang compiler.

So in my case I configure my cmake script with gcc but out of gradle scripting, but I think it will be the same, I add -mapcs-frame in the CMAKE_CXX_FLAGS.

externalNativeBuild {
        cmake {
            arguments "-DANDROID_PLATFORM_LEVEL=${11}",
                    '-DANDROID_TOOLCHAIN=gcc', 
                    '-DANDROID_STL=gnustl_static',
                    'DCMAKE_CXX_FLAGS=-mapcs-frame'
        }
    }

I know that if you use clang compile may be this flag could not work. But my idea was to share my experience with android native debugging.

I Hope this clues could help you.

Cheers.
Unai.


The reason seems to be, that a release version of the lib is created, which does not support debugging, even if the app is built with debug options.

Solution:

To solve this issue, do the following workaround. It ensures that a debug version is built.


In your apps build.gradle change:

compile project(':nativelib')

to

compile project(path: ':nativelib' , configuration: 'debug')

In the libs build.gradle add:

android {

    publishNonDefault  true //this line

    compileSdkVersion 24
    buildToolsVersion "25.0.2"
    defaultConfig {
    ...
    }
...
}    

Updates:

See the google issue for updates:

https://code.google.com/p/android/issues/detail?id=222276