6

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.

Konrad Krakowiak
  • 12,285
  • 11
  • 58
  • 45
Alex Mads
  • 81
  • 1
  • 4
  • Please post the resulting errors to help the community answer your question. – Daniel Jun 19 '15 at 22:09
  • Try [putting `-dontobfuscate`](http://proguard.sourceforge.net/manual/usage.html#dontobfuscate) in your ProGuard rules. – CommonsWare Jun 19 '15 at 22:47
  • @CommonsWare thank. by your way, i found more solution here http://stackoverflow.com/questions/25843122/how-to-remove-unused-resources-from-libraries thats help. – Alex Mads Jun 20 '15 at 00:10

1 Answers1

2

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.

T. Neidhart
  • 6,060
  • 2
  • 15
  • 38