Shlublu Shlublu - 1 month ago 15
Android Question

How to modify proguard-android-optimize.txt with AndroidStudio 2.2?

With Android Studio 2.2 and the new build system, the ProGuard files available in

$ANDROID_HOME
are no longer used:


2.2.0-alpha4 (2016/6/23)

...

ProGuard files returned by
getDefaultProguardFile
are distributed with
the plugin now, the ones in
$ANDROID_HOME
are no longer used.


I used to use a modified version of
proguard-android-optimize.txt
suitable for my needs. Now, the file
proguard-android-optimize.txt-2.2.2
located in
<project_path>\build\intermediates\proguard-files
is generated at build time.

So how can I do now, should there be a way?

Of course, I can (probably?) modify each and every project-specific
.pro
files to reach the same goal, but the advantage of changing
proguard-android-optimize.txt
was to do it once for all.

Answer

Add a ProGuard file to the proguardFiles property from outside of the project:

proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'),
        'proguard-rules.pro', '/path/to/proguard-optimize.pro'
Comments