Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

enable proguard only for remove unused code

My app using some jar libs with too many methods, but in fact used only 2-3 methods from this libs. Total size of this libs more than 2Mb. I don't need all of it and i want to shrink my apk with ProGuard.

I need to enable ProGuard and configure it only for remove unused code and shrink apk size. but I don't know how. I don't want to obfuscate my app and etc. only shrink final size.

I try to enable proguard by

minifyEnabled true

but it got only errors and nothing.

like image 635
Alex Mads Avatar asked Jun 19 '15 21:06

Alex Mads


1 Answers

To only shrink your application you should do the following:

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

The proguard-shrink-only.txt should contain the following options:

-dontobfuscate
-dontoptimize

The proguard-project.txt should contain your project specific keep rules that might be needed for classes that are used via reflection.

like image 113
T. Neidhart Avatar answered Oct 09 '22 17:10

T. Neidhart