When it comes to enormous proportions, it is mainly about resources, not about minimizing java code. Therefore, you can try a few things mentioned below.
- Proguard is working on Java code. Unfortunately, it does not work in the resources folder. As a result, if the my_image image is not used in res / drawable, Proguard only shares its reference in the R class, but keeps the linked image in place.
- Lint is a static code analyzer that helps you discover all unused resources with a simple call. / gradlew lint. It creates an HTML report and provides an exhaustive list of resources that look unused in the "UnusedResources: Unused resources" section. Itβs safe to delete these resources until you access them through reflection in your code.
However, Lint can tell you where the unused resources are located, but using fb sdk it will be difficult to delete the resources, since it comes from the maven repository.
Minimizing resource configurations (build.gradle) For example, Fb sdk provides support for all languages ββthat you may not need, or for all folder images, such as mdpi, that may not be useful to you.
defaultConfig { resConfigs "en", "de", "fr", "it" resConfigs "nodpi", "hdpi", "xhdpi", "xxhdpi", "xxxhdpi" }
If all this does not work, it means that either your own code inflates your apk, where splitting the application binary interface can help reduce the size of your apk.
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 can be done here when I opened the facebook sdk gradle file ... it has several transitive dependencies, which is redundant and may conflict with your support version so that you can either import them into 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 can be removed from the final thick jar, as you can already use support dependencies in your project that are too different or conflicting. That way, you could ideally exclude transitive dependencies based on your requirements, as shown below.
compile ('com.facebook.android:facebook-android-sdk:4.+') { exclude group: 'com.android.support' //by group }