调试不能与Android Studio一起使用的C ++/本机库模块(已使用Cmake) [英] Debugging C++/native library modules not working with Android Studio (Cmake used)

查看:192
本文介绍了调试不能与Android Studio一起使用的C ++/本机库模块(已使用Cmake)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在调试库模块的C ++文件时遇到麻烦.

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

一般可以吗?

如果应用程序项目包含c ++代码,则调试工作正常. 但是我想将C ++代码移至库模块.

The debugging works fine if the application project contains the c++ code. But I want to move the C++ Code to a library module.

启动会话时的错误消息:

现在启动本机调试会话

注意!找不到符号目录-请检查您的本机调试配置

Attention! No symbol directories found - please check your native debug configuration

我的lib的分级文件:

apply plugin: 'com.android.library'


android {
compileSdkVersion 24
buildToolsVersion "25.0.2"
defaultConfig {

    minSdkVersion 16
    targetSdkVersion 21
    versionCode 1
    versionName "1.0"
    externalNativeBuild {
        cmake {
            arguments "-DANDROID_PLATFORM_LEVEL=${11}",
                    '-DANDROID_TOOLCHAIN=clang', '-DANDROID_STL=gnustl_static'
        }
    }
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
externalNativeBuild {
    cmake {
        path "CMakeLists.txt"
    }
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-annotations:24.2.0'
}

在运行配置中,调试器设置为自动

添加项:

我正在使用:

等级:2.2.3

Android Studio:2.2.3

Android Studio : 2.2.3

在LLLB控制台中,我使用以下命令检查了断点列表:

in the LLLB Console, i checked the breakpoint List with:

断点列表-v

我所有的检查站都在这里列出.

all my checkpoints are listed there.

无法正常工作的断点

1: file = 'C:\android-dev\...\test.cpp', line = 19, exact_match = 0

..仅此而已

工作断点

1: file = 'C:\android-dev\...\test.cpp', line = 19, exact_match = 0
    1.1: 
      module = C:\android-dev\...\test.so
      compile unit = gl_code.cpp
      function = testFunc(..)
      location = C:\android-dev\...\test.cpp:16
      address = 0x0000007f871d068c
      resolved = true
      hit count = 1   

推荐答案

原因似乎是,创建了lib的发行版, 即使该应用是使用调试选项构建的,它也不支持调试.

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.

解决方案:

要解决此问题,请执行以下解决方法.它可以确保构建调试版本.

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

在您的应用程序中build.gradle更改:

In your apps build.gradle change:

compile project(':nativelib')

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


在libs build.gradle中添加:


In the libs build.gradle add:

android {

    publishNonDefault  true //this line

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

更新:

有关更新,请参见Google问题:

See the google issue for updates:

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

这篇关于调试不能与Android Studio一起使用的C ++/本机库模块(已使用Cmake)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆