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

前端 未结 3 1209
刺人心
刺人心 2021-02-06 04:07

I\'m having trouble debugging C++ files of my library module.

Is this possible in general?

The debugging works fine if the application project contains the c++ c

相关标签:
3条回答
  • 2021-02-06 04:44

    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

    0 讨论(0)
  • 2021-02-06 04:50

    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.

    0 讨论(0)
  • 2021-02-06 05:01

    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.

    0 讨论(0)
提交回复
热议问题