How to debug Android library module in Android Studio?

I have an Android Studio project that contains a library module that is added to it as another gradle project. I would like to debug library code and set breakpoints on it.

What gradle options should I use if I want to debug a library module when running the application on an emulator or on a real device?


Update 1

this is the settings.gradle file:

include ':app'
include':my-library'
+6
source share
3 answers

After several days of struggle, I found the correct configuration for debugging the library module:

1- , :

2- app library-module. , app build.gradle:

compile project(':library-module')

3- , app build.gradle

4- app library-module

minifyEnabled true
shrinkResources true
+2

debug Release debugable

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        debuggable true
        jniDebuggable true
    }
    debug {
        debuggable true
        jniDebuggable true
        minifyEnabled false
    }
}
+1

:

|- myApplication
|  |- settigs.gradle
|  |- build.gradle
|     ...
|- myLibrary
   |- build.gradle
      ...

settings.gradle:

include ':myLibrary'
project(':myLibrary').projectDir = new File(settingsDir, '../myLibrary')

build.gradle( )

compile project(':myLibrary')

Your library just turns on, and you can debug and set breakpoints, as in the application.

0
source

Source: https://habr.com/ru/post/1015368/


All Articles