11
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Proguardメモ

Posted at

様々なライブラリを使っているプロジェクトで設定した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

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

Retrofit

# 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

-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

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

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

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

Dagger2

不要でした。

EventBus

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

JsonPullParser

不要でした。

11
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?