Android debugging with minifyEnabled true
No ..but you should avoid using it on debug build. it will slow down your application .it is usefull when you release the APK for testing purposes but before that, Make you aware of using MinifyEnabled. follow this link. it is used for enable the code shrinking.(Unused codes will be shrinked).
See official documentation.
It is already possible to debug minified applications.
First, edit your proguard-rules.pro
and add lines:
-dontobfuscate
-keepattributes SourceFile,LineNumberTable
Also, make sure to comment out this line:
# -renamesourcefileattribute SourceFile
Then, edit your application build.gradle
file and define your debug build type in the following way:
debug {
minifyEnabled true
useProguard false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
All of these changes are necessary(if you skip keepattributes
and renamesourcefileattribute
, then debugging will work, but logging will still point to wrong place in the code)
Then, run the application with debugger.
The logging will now point you exactly to the proper place in the code. Also, if there are any breakpoints set, these will be executed properly. Android Studio will allow you to investigate variables, check for conditions and evaluate the code.
Remember to remove the changes in the proguard-rules.pro
file before you build the release. You can also define debug and release settings in separate proguard files.