Help us understand the problem. What is going on with this article?

ProGuardのメモ

More than 5 years have passed since last update.

まだよくわからないけど、利用するライブラリによってProGuardの指定をきちんとしないと動かなかったりするらしい。

Google Play Services

ドキュメントによると以下の指定が必要らしい。

-keep class * extends java.util.ListResourceBundle {
  protected Object[][] getContents();
}

-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable {
  public static final *** NULL;
}

-keepnames @com.google.android.gms.common.annotation.KeepName class *
-keepclassmembernames class * {
  @com.google.android.gms.common.annotation.KeepName *;
}

-keepnames class * implements android.os.Parcelable {
  public static final ** CREATOR;
}

OrmLite

OrmLite DAOはリフレクションを使うため、下記指定が必要らしい。

-keep class com.j256.**
-keepclassmembers class com.j256.** { *; }
-keep enum com.j256.**
-keepclassmembers enum com.j256.** { *; }
-keep interface com.j256.**
-keepclassmembers interface com.j256.** { *; }

Logger

Caused by: java.lang.ClassCastException: The application has specified that a custom LogFactory implementation should be used but Class 'org.apache.commons.logging.impl.LogFactoryImpl' cannot be converted to 'xc'. Please check the custom implementation. Help can be found @http://commons.apache.org/logging/troubleshooting.html.
…みたいなエラーメッセージが出る場合は、下記指定をすると良いらしい。

-keep public class org.apache.commons.** { *; }

コンストラクター

コードから明示的に使われていないコンストラクターが除去されてしまう場合は、除去しない設定を書く。

-keepclassmembers class * {
   public <init>(android.content.Context);
}

EventBus

EventBusはリフレクションでonEventメソッドを探すので、下記指定が必要。

-keepclassmembers class ** {
     public void onEvent(**);
 }

JSONマッピング用、DBエンティティ用クラス

GsonみたいなJSONマッピング機能やOrmLiteのようなORM機能はリフレクションでフィールドを取得するので、それらのデータを表すためのクラスはフィールドを削除したりしない指定が必要。

-keepattributes *Annotation*
-keepclassmembers class com.my.app.data.using.ormlite.** { *; }

ProGuardめんどくさいよう…

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした