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

前端 未结 5 1845
不知归路
不知归路 2020-12-14 14:48

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 hitt

5条回答
  •  执念已碎
    2020-12-14 15:15

    I think Marcin's argument above makes sense (much as there are situations that require debugging release builds), so here is a slight variation of the accepted answers that worked for me:

    android {
        ...
        buildTypes {
            release {
                shrinkResources false # this was key
                minifyEnabled false # seems that it can't be set to true if shrinkResources is false
                proguardFiles getDefaultProguardFile('proguard-android.txt'),
                        'proguard-rules.pro'
            }
        }
    }
    

    Adapted from the official docs

    NOTE:

    When I set minifyEnabled true, the following crash occurred on app launch:

    java.lang.RuntimeException: Unable to instantiate application co.mycompany.app.MyApp: java.lang.ClassNotFoundException: Didn't find class "co.mycompany.app.MyApp" on path: DexPathList...
    

提交回复
热议问题