How to debug the Android App in release mode using Android studio

Bazi Paleri picture Bazi Paleri · Nov 19, 2015 · Viewed 23.7k times · Source

For some reason I have to run my Android App in release mode.I have to run through the code when running the app just like we use in debug mode. My break points are not hitting when I run in release mode, I have added android:debuggable="true" in manifest. Still the breakpoint is not hitting. Any help.

Thanks in Advance

Answer

once2go picture once2go · Nov 19, 2015

In your gradle file, you must add debuggable ability in your release flavor.

buildTypes {
    release {
        debuggable true
        minifyEnabled false
        signingConfig signingConfigs.release
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
    }
    debug {
        debuggable true
        minifyEnabled false
        applicationIdSuffix '.debug'
    } 
}

signingConfig is release configuration it must be added in gradle file in android{} block, something like this:

signingConfigs {
    release {
        keyAlias 'YourAppKey'
        keyPassword 'somePassword'
        storeFile file('appkeyfile.jks')
        storePassword 'somePassword'
    }
}