Enable proguard only to remove unused code

My application uses some jar libs with too many methods, but actually only 2-3 methods from these libraries are used. The total size of these files is more than 2 MB. I donโ€™t need all this and I want to compress my apk with ProGuard.

I need to enable ProGuard and configure it only to remove unused code and reduce the size of the APK. but I donโ€™t know how to do it. I do not want to confuse my application, etc., Only reducing the final size.

I am trying to enable proguard with

minifyEnabled true 

but he received only errors and nothing.

+5
source share
1 answer

To just compress the application, you have to do the following:

 release { proguardFile getDefaultProguardFile('proguard-android.txt') proguardFile 'proguard-shrink-only.txt' proguardFile 'proguard-project.txt' } 

proguard-shrink-only.txt should contain the following parameters:

 -dontobfuscate -dontoptimize 

proguard-project.txt should contain your project-specific rules, which may be required for classes that are used in reflection.

0
source

All Articles