I have an Android project with the file proguard-rules.pro for the app module, which contains only the following:
# ProGuard rules -dontobfuscate -dontwarn android.arch.util.paging.CountedDataSource -dontwarn android.arch.persistence.room.paging.LimitOffsetDataSource
I do not hold anything myself. All -keep rules come from something else, be it the rules provided by getDefaultProguardFile('proguard-android-optimize.txt') , or from rules packaged in libraries.
However, the material is stored in what I do not use. If I use the Android Studio APK Analyzer on my release build while many things are removed by ProGuard, many other things are stored that I donโt reference.
For example: through transitive dependencies, I have a support library module that contains a ViewPager in the application dependency tree. However, I am not currently using ViewPager in this application. Despite this, something forces him to save, since APK Analyzer shows 107 specific methods for android.support.v4.view.ViewPager , including its constructor.
I could use various ProGuard options to keep track of why this persists. However, this does not come from my rules. There is no -keep that needs to be fixed - -keep comes from someone else, presumably a Google engineer.
So how do I get rid of ViewPager ? Is there a way that I can override the -keep rule that causes it to be saved (e.g. using allowshrinking )? If so, how does ProGuard called by Android Studio determine whose -keep rule wins?
source share