如何在 Android Studio 中调试 android 库模块? [英] How to debug android library module in Android Studio?
问题描述
我有一个包含库模块的 Android Studio 项目,该项目作为另一个 gradle 项目添加到其中.我想调试库代码并在其上设置断点.
I have an Android Studio project which contains a library module, which is added as another gradle project to it. I would like to debug the library code and set breakpoints on it.
如果我想在模拟器或真实设备上运行应用程序时调试库模块,我应该使用什么 gradle 设置?
What gradle settings should I use, if I want to debug a library module while running the app on emulator or real device ?
更新 1
这是 settings.gradle 文件:
this is the settings.gradle file :
include ':app'
include':my-library'
推荐答案
经过几天的努力,我找到了能够调试库模块的正确配置:
After a few days struggling I found the right configuration for being able to debug the library module :
1- 创建一个包含两个模块的项目,app 和 library-module
1- Create a project which consists of two modules, the app and the library-module
2- 添加直接模块依赖到 app
,来自 library-module
.这就是 app
的 build.gradle :
2- Add direct module dependency to app
, from the library-module
. This is what the app
's build.gradle :
compile project(':library-module')
3- 删除在 app
build.gradle
3- Remove any automatic signing configuration added in the app
build.gradle
4- 从 app
和 library-module
minifyEnabled true
shrinkResources true
这篇关于如何在 Android Studio 中调试 android 库模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!