I want to use the facebook sdk just for analytics, is there an optimized proguard configuration that I could use to strip out the rest?
When it comes down to huge size, it is mostly about the resources rather than worrying about minimising java code itself. So you could actually try out a few things mentioned below.
However Lint can tell you where are unused resources, but with fb sdk it will be hard to delete the resources as it comes from maven repository.
Minimising Resource Configuration (build.gradle) For eg Fb sdk provides support all languages which you might not need, or all folders images like mdpi which may not be useful for you.
defaultConfig {
resConfigs "en", "de", "fr", "it"
resConfigs "nodpi", "hdpi", "xhdpi", "xxhdpi", "xxxhdpi"
}
If all of this doesn't work that means either native code is bloating your apk, where application binary interface split might help reducing your apk size.
ABI Split:-
splits {
density {
enable true
reset()
include "ldpi", "mdpi"
}
abi {
// Enables building multiple APKs per ABI.
enable true
// By default all ABIs are included, so use reset() and include to specify that we only
// want APKs for x86, armeabi-v7a, and mips.
// Resets the list of ABIs that Gradle should create APKs for to none.
reset()
// Specifies a list of ABIs that Gradle should create APKs for.
include "x86", "armeabi-v7a", "mips"
// Specifies that we do not want to also generate a universal APK that includes all ABIs.
universalApk false
}
}
I think something could be done here as I opened facebook sdk gradle file ... it has few transitive dependencies, which is redundant and might conflict with your support version so you could either import the same in your files
dependencies {
// Facebook Dependencies
compile 'com.android.support:support-v4:25.3.1'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.android.support:customtabs:25.3.1'}
It could be removed from final fat jar as you might be already using the support dependencies in your project that too different or conflicting ones .. so you could ideally exclude transitive dependencies based on your requirements something like below
compile ('com.facebook.android:facebook-android-sdk:4.+') {
exclude group: 'com.android.support' //by group
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With