Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Google DevFest '17 | App shrinkage with ProGuar...

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest. →

Google DevFest '17 | App shrinkage with ProGuard | Gradle Build System

Talk delivered at GDG DevFest'17 on 29th Oct '17.
I talk about leveraging the proguard rules to go the extra mile to shrink your APK.

Avatar for Ishan Guliani

Ishan Guliani

October 29, 2017

Other Decks in Programming

Transcript

  1. Ishan Guliani VP Engineering @ Applop | Former GSA Certified

    Software Product Manager Certified Mobile Applications Engineer /ishanguliani Shrink it down, Scale it up : Android APKs
  2. By the end of the session ? • Remove some

    extra bytes • Get insight into the build system • Explore shrinkage options • Feel confident
  3. The steps • Semi tech • Sample code run through

    • 11 to 7 effect -- (11 MB to 7MB)^n
  4. Key terms to note : - • Project level build

    file • Proguard ◦ optimizes the bytecode ◦ removes unused code instructions ◦ Obfuscates the remaining classes, fields, and methods with short names. • Dex class files have 64K reference limit • APK Analyser • APK comparison • Product flavors
  5. It all starts from the build.gradle (module) android { ...

    buildTypes { release { minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } productFlavors { flavor1 { } flavor2 { proguardFile 'flavor2-rules.pro' }...
  6. Classes get leaved out when • When your app references

    a class only from the AndroidManifest.xml file • When your app calls a method from the Java Native Interface (JNI) • When your app manipulates code at runtime (such as with reflection or introspection)
  7. Keep classes in the code Adding the following line to

    proguard-rules.pro saves firebase POJO from being removed during shrinking --
  8. Where to go from here... • Explore advanced optimisations with

    proguard-android-optimize.txt • Study gradle plugin configurations available • Feel more confident about deploying production builds