Search code examples
androidnavigation-drawerandroid-architecture-componentsandroid-architecture-navigation

hamburger icon display in release build in place of back icon if move from one fragment to another fragment


I am using Navigation Architecture.

For debug build :

debug {
        debuggable true
        minifyEnabled false
        useProguard false
    }

and For release build :-

 release {

        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
  1. I am using navigation drawer and when app is opened show hamburger icon in Toolbar. Thanks in advance for help.
  2. But when I am moving from one fragment to another fragment . I have to show back icon(Navigation back).
  3. In debug build it works fine.
  4. But in release build ,hamburger icon is showing in toolbar in place of back icon.

But I need to show back icon in place of hamburger icon in release build.


Solution

  • I ran into this, I inspected logs and found an error that suggested something went wrong with obfuscation of hamburger/back arrow drawable in the toolbar. It said something like - startAnimation method could not be found.

    Now I dont really know whats the real problem behind it, I just added these lines in proguard file and it worked again:

    -keep class androidx.appcompat.app.ActionBarDrawerToggle{}
    
    -keep class androidx.appcompat.graphics.drawable.DrawerArrowDrawable{ *; }