I'm using MobileFirst 7 library for a native Android application but have found it severely increases the dex method count of my Android application (pushing it over the 65,536 limit).
Per Adding the IBM MobileFirst Platform Foundation SDK to a new or existing application with Android Studio article, I added the following to my build.gradle
:
compile group: 'com.ibm.mobile.foundation',
name: 'ibmmobilefirstplatformfoundation',
version: '7.1.0.0',
ext: 'aar',
transitive: true
According to methodscount.com, the MobileFirst library (and it's dependencies) pulls in a whopping 39,364 methods (60% of the available dex method count)!
I figured Proguard might help reduce the impact of using MobileFirst, but found that the example proguard-project.txt has the following directive:
-keep class com.google.** { *;}
As I understand it, this effectively tells Proguard not to remove any of the Google Guava methods. There are other libraries that MobileFirst pulls in, but I started with Guava because it was the largest.
Then I decided to look into how much MobileFirst utilized the Guava library:
$ unzip ibmmobilefirstplatformfoundation-7.1.0.aar
$ jadx --output-dir temp/ classes.jar
$ grep -roh . -e 'com.google.common.*' | sort | uniq
Which found zero references to any of the Guava library (granted the decompiler may be missing some of the references) but it does seem as though the Guava dependency may be excluded?
compile(group: 'com.ibm.mobile.foundation',
name: 'ibmmobilefirstplatformfoundation',
version: '7.1.0.0',
ext: 'aar',
transitive: true) {
exclude group: 'com.google.guava', module: 'guava'
}
If that is not the case (and excluding Guava would be a problem) then:
- are there better Proguard rules that can be used to only keep the methods that are necessary in the MobileFirst dependencies?
- can other large libraries that MobileFirst depends on also be excluded?