Android Studio's debugger not stopping at breakpoints within library modules

前端 未结 7 1258
难免孤独
难免孤独 2020-12-03 00:27

At the moment I\'m developing an Android app that is based on third party code. I started to set breakpoints for understanding the code and soon ran into a problem. Suddenly

相关标签:
7条回答
  • 2020-12-03 00:56

    In fact, there's a known issue in Android Studio: Gradle plugin does not propagate debug/release to dependencies. It seems to happen in A Studio 1.4 and 1.5 at least.

    When an app is compiled in debug, its modules are in fact compiled in release. That's why proguard may be enabled in debug.

    I recommend this answer that worked for me.

    0 讨论(0)
  • 2020-12-03 00:57

    I had a problem with trying to debug Kotlin code. The debugger wasn't stoping at any of the breakpoints. It turns out it was an issue with Instant run. I removed all the build directories from my project then I uninstalled the app after that I disabled Instant run.

    To disable Instant run go to File > Settings > Build, execution, deployment > Instant run > Uncheck Enable Instant Run

    0 讨论(0)
  • 2020-12-03 00:58

    I kind of solved it, although I don't fully understand it yet. The problem was that ProGuard still was active like @Feantury suggested. I don't know why that was the case as I had specified minifyEnabled false in every build.gradle position I could imagine, but it seems it didn't have any effect.

    As I had a crash just a few minutes ago, I saw lines in the stacktrace that looked like so:

    java.lang.NullPointerException
            at com.example.MyClass(Unknown Source)
            ...
    

    That made ProGuard the number one suspect for me. After some searching around, I found another SO question that deals with the Unknown Source problem. I tried the suggested solution for debugging with ProGuard enabled and voilà it worked!

    Simply add the following lines to proguard-rules.txt:

    -renamesourcefileattribute SourceFile    
    -keepattributes SourceFile,LineNumberTable
    
    0 讨论(0)
  • 2020-12-03 00:59

    As stated in the comments of this issue, setting minifyEnabled false in the debug build is the best practice. By setting this variable in the app module you are disabling the entire proguard build process. It is useful when optimizing the release build, but gives some problems if you are testing and developing.

    0 讨论(0)
  • 2020-12-03 01:00

    I discovered the problem to be that Android Studio was in offline mode. When I changed from offline mode this allowed debugging to work effectively.

    0 讨论(0)
  • 2020-12-03 01:12

    In my case, I had to set debug type to Java Only.

    Go to Edit Configurations.

    Set debug type to Java Only

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