Proguard settings in Android development


The other day, I was trying to export a signed package. Then, the Proguard has output many “warning” messages. So, I have failed to export it.

I reproduce the same situation on a test project again. Then, I got same messages like the following.
Proguard warning messages

These appear to be the ones for the “support library”. But I did not have to introduce the library to reproduce them.

I’ve tried the trial and error. Then, I have found that I can solve this problem when I change the setting method of the Proguard.

[Previous setting method]

  1. Open “project.properties” directly under the project.
  2. Add a line that was described as follows:
    proguard.config=proguard.cfg
  3. Describe the settings with reference to example of the Examples of Proguard Manual in “proguard.cfg”

[New setting method]

  1. Open “project.properties”.
  2. Enable the assination for “proguard.config” that is commented out.(Remove # at the begining of the line) as follows:
    proguard.config=${sdk.dir}toolsproguardproguard-android.txt:proguard-project.txt
  3. Disable the assination for “proguard.config” that is used previously.(Add # at the begining of the line or delete the line) as follows:
    #proguard.config=proguard.cfg
  4. Add your own specification in “proguard-project.txt” that is directly under the project.(“proguard-project.txt” is automatically generated when generating the project.
    If it is not exited, you can make it.)
  5. Delete “proguard.cfg” (just making sure).

In “New setting”, You define the Proguard settings with “proguard-android.txt” under the directory of Android-SDK and “proguard-project.txt” directly under your project.
In “proguard-android.txt”, the definitions recommended for Android project are described. Because SDK and Proguard are linked,  problems will be less likely to occur.
And because your own settings are defined in “proguard-project.txt” under your project, you are easy to manage the settings.