调试不使用Android Studio的C /本机库模块(使用Cmake)

我在调试库模块的C文件时遇到问题.

一般来说这可能吗?

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

启动会话时出现错误消息:

现在启动本机调试会话

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

我的lib的gradle文件:

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'
}

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

加法:

我正在使用:

Gradle:2.2.3

Android Studio:2.2.3

在LLLB控制台中,我检查了断点列表:

断点列表-v

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

不工作的断点

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

..就这样

工作断点

1: file = 'C:\android-dev\...\test.cpp',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的发布版本,
它不支持调试.
即使应用程序是使用调试选项构建的.

解:

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

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

compile project(':nativelib')

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

在libs build.gradle中添加:

android {

    publishNonDefault  true //this line

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

更新:

有关更新,请参阅相应的Google问题:

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

相关文章

Android 如何解决dialog弹出时无法捕捉Activity的back事件 在...
Android实现自定义带文字和图片的Button 在Android开发中经常...
Android 关于长按back键退出应用程序的实现最近在做一个Andr...
android自带的时间选择器只能精确到分,但是对于某些应用要求...