Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
Help us understand the problem. What is going on with this article?

ProGuard設定まとめ

More than 5 years have passed since last update.

どこかにまとめサイトがあれば便利なんですけどねぇ(´・ω・`)

追記 aarで配布されていものはGradleがproguardの設定を自動的に追加するので個別の設定はする必要がないようです。 参考資料

追記2 play-services-adsのaarに入っているproguard.txtは役に立たないので別途設定が必要でした m(_ _)m

ActionBarSherlock

proguard-project.txt
-keep class android.support.v4.app.** { *; }
-keep interface android.support.v4.app.** { *; }
-keep class com.actionbarsherlock.** { *; }
-keep interface com.actionbarsherlock.** { *; }

-keepattributes *Annotation*

http://actionbarsherlock.com/faq.html

ACRA

proguard-project.txt
#ACRA specifics
# we need line numbers in our stack traces otherwise they are pretty useless
-renamesourcefileattribute SourceFile
-keepattributes SourceFile,LineNumberTable

# ACRA needs "annotations" so add this... 
-keepattributes *Annotation*

# keep this class so that logging will show 'ACRA' and not a obfuscated name like 'a'.
# Note: if you are removing log messages elsewhere in this file then this isn't necessary
-keep class org.acra.ACRA {
    *;
}

# keep this around for some enums that ACRA needs
-keep class org.acra.ReportingInteractionMode {
    *;
}

-keepnames class org.acra.sender.HttpSender$** {
    *;
}

-keepnames class org.acra.ReportField {
    *;
}

# keep this otherwise it is removed by ProGuard
-keep public class org.acra.ErrorReporter
{
    public void addCustomData(java.lang.String,java.lang.String);
    public void putCustomData(java.lang.String,java.lang.String);
    public void removeCustomData(java.lang.String);
}

# keep this otherwise it is removed by ProGuard
-keep public class org.acra.ErrorReporter
{
    public void handleSilentException(java.lang.Throwable);
}

https://github.com/ACRA/acra/wiki/Proguard

Jsoup

proguard-project.txt
-keep public class org.jsoup.** {
public *;
}

http://www.jormula.com/dev/2013/01/29/tutorial-how-to-solve-force-close-crash-using-jsoup-with-proguard-in-android/

Gson

proguard-project.txt
# Gson uses generic type information stored in a class file when working with fields. Proguard
# removes such information by default, so configure it to keep all of it.
-keepattributes Signature

# For using GSON @Expose annotation
-keepattributes *Annotation*

# Gson specific classes
-keep class sun.misc.Unsafe { *; }
#-keep class com.google.gson.stream.** { *; }

さらにアプリごとにGsonでシリアライズ・デシリアライズするクラスはkeepする必要がある

# Application classes that will be serialized/deserialized over Gson
-keep class com.google.gson.examples.android.model.** { *; }

http://google-gson.googlecode.com/svn/trunk/examples/android-proguard-example/proguard.cfg

ButterKnife

7.0以前

proguard-project.txt
-keep class butterknife.** { *; }
-dontwarn butterknife.internal.**
-keep class **$$ViewInjector { *; }

-keepclasseswithmembernames class * {
    @butterknife.* <fields>;
}

-keepclasseswithmembernames class * {
    @butterknife.* <methods>;
}

7.0以降

proguard-project.txt
-keep class butterknife.** { *; }
-dontwarn butterknife.internal.**
-keep class **$$ViewBinder { *; }

-keepclasseswithmembernames class * {
    @butterknife.* <fields>;
}

-keepclasseswithmembernames class * {
    @butterknife.* <methods>;
}

http://jakewharton.github.io/butterknife/

Okio (OkHttp)

proguard-project.txt
-dontwarn java.nio.file.*
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement

https://github.com/square/okio/issues/58

Retrofit

proguard-project.txt
-dontwarn rx.**
-dontwarn com.squareup.okhttp.*
-dontwarn com.google.appengine.api.urlfetch.*

https://github.com/square/retrofit/issues/435

Otto

proguard-project.txt
-keepclassmembers class ** {
    @com.squareup.otto.Subscribe public *;
    @com.squareup.otto.Produce public *;
}

http://square.github.io/otto/

Joda-Time

proguard-project.txt
-dontwarn org.joda.convert.**

Facebook SDK

Gradleが自動的にproguardの設定を追加するので個別の設定はする必要がないようです。

https://developers.facebook.com/docs/android/getting-started#proguard

Google Play Services SDK

Gradleが自動的にproguardの設定を追加するので個別の設定はする必要がないようです。

以下の設定はeclipseで組み込む場合に必要な設定です。

proguard-project.txt
-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;
}

https://developers.google.com/android/guides/setup

In App Billing

-keep class com.android.vending.billing.**

http://developer.android.com/intl/ja/google/play/billing/billing_best_practices.html#obfuscate

AdMob(旧)

proguard-project.txt
-dontwarn com.google.ads.**
-keep class com.google.ads.** {*;}

AdMob(Google Play Services SDK)

-keep public class com.google.android.gms.ads.** {
   public *;
}

-keep public class com.google.ads.** {
   public *;
}

https://developers.google.com/mobile-ads-sdk/docs/admob/android/faq?hl=ja#proguard

MoPub SDK

proguard-project.txt
# Keep public classes and methods.
-keepclassmembers class com.mopub.** { public *; }
-keep public class com.mopub.**
-keep public class android.webkit.JavascriptInterface {}

# Explicitly keep any custom event classes in any package.
-keep class * extends com.mopub.mobileads.CustomEventBanner {}
-keep class * extends com.mopub.mobileads.CustomEventInterstitial {}
-keep class * extends com.mopub.nativeads.CustomEventNative {}

# Support for Android Advertiser ID.
-keep class com.google.android.gms.common.GooglePlayServicesUtil {*;}
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient {*;}

https://github.com/mopub/mopub-android-sdk/blob/master/mopub-sample/proguard.cfg

Millennial Media SDK

proguard-project.txt
-keepclassmembers class com.millennialmedia.android.* { 
public *; 
} 
-keep class com.millennialmedia.android.**

# When using ProGuard and not SpeechKit, add the following line to their proguard-project.txt:
-dontwarn com.millennialmedia.android.NVASpeechKit*

http://docs.millennialmedia.com/android-SDK/AndroidFAQ.html

InMobi Ad SDK

proguard-project.txt
-keep class com.inmobi.** { *; }
-dontwarn com.inmobi.**

https://www.inmobi.com/support/integration/23817448/22051163/android-sdk-integration-guide/

Flurry

-keep class com.flurry.** { *; }
-dontwarn com.flurry.**
-keepattributes *Annotation*,EnclosingMethod,Signature
-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet, int);
}

# Google Play Services library
-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;
}

#If you are using the Google Mobile Ads SDK, add the following:
# Preserve GMS ads classes
-keep class com.google.android.gms.ads.** { *;
}
-dontwarn com.google.android.gms.ads.**


#If you are using the InMobi SDK, add the following:
# Preserve InMobi Ads classes
-keep class com.inmobi.** { *;
}
-dontwarn com.inmobi.**
#If you are using the Millennial Media SDK, add the following:
# Preserve Millennial Ads classes
-keep class com.millennialmedia.** { *;
}
-dontwarn com.millennialmedia.**

https://developer.yahoo.com/flurry/docs/publisher/code/android/

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