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

Proguardメモ

More than 3 years have passed since last update.

様々なライブラリを使っているプロジェクトで設定したProguardのメモです。
利用したライブラリは以下の通りです。

  • OkHttp 2.4.0
  • Retrofit 1.9.0
  • RxJava 1.0.12
  • Dagger 2.0
  • ButterKnife 7.0.1
  • EventBus 2.4.0
  • JsonPullParser 1.6.2

buildToolsVersionは23.0.1です。

プロジェクトのbuild.gradle

buildTypes {
    release {
        minifyEnabled true
        proguardFiles 'proguard-android.txt'
        proguardFiles 'proguard-project.txt'
    }
}

proguard-android.txtはAndroidSDKのものをそのまま使い、proguard-project.txtとして以下の設定を使いました。重複している記述がいくつかありますが、相反する記述はないのでそのまま続けて書いています。

OkHttp

https://github.com/krschultz/android-proguard-snippets/blob/master/libraries/proguard-square-okhttp.pro

# OkHttp
-keepattributes Signature
-keepattributes *Annotation*
-keep class com.squareup.okhttp.** { *; }
-keep interface com.squareup.okhttp.** { *; }
-dontwarn com.squareup.okhttp.**

Retrofit

https://github.com/krschultz/android-proguard-snippets/blob/master/libraries/proguard-square-retrofit.pro

# Retrofit 
-keep class com.squareup.okhttp.** { *; }
-keep class retrofit.** { *; }
-keep interface com.squareup.okhttp.** { *; }

-dontwarn com.squareup.okhttp.**
-dontwarn okio.**
-dontwarn retrofit.**
-dontwarn rx.**

-keepclasseswithmembers class * {
    @retrofit.http.* <methods>;
}

RxJava

https://gist.github.com/jonikarppinen/07de110fd0d9ed90b202

-dontwarn sun.misc.**

-keepclassmembers class rx.internal.util.unsafe.*ArrayQueue*Field* {
   long producerIndex;
   long consumerIndex;
}

-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueProducerNodeRef {
    rx.internal.util.atomic.LinkedQueueNode producerNode;
}

-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueConsumerNodeRef {
    rx.internal.util.atomic.LinkedQueueNode consumerNode;
}

ButterKnife

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

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

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

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

Dagger2

不要でした。

EventBus

https://github.com/greenrobot/EventBus/issues/6

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

JsonPullParser

不要でした。

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
ユーザーは見つかりませんでした