Skip to content

Proguard configuration

xcesco edited this page Jun 12, 2018 · 8 revisions

Configure proguard

To obfuscate your code with Kripton, usually you have to modify proguard-rules.pro file to configure proguard for you project. For Kripton persistence library you have just to add this lines:

##############################
# Kripton Persistence Library
##############################
-keep class com.abubusoft.kripton.annotation.** { *; }
-keep class com.abubusoft.kripton.android.annotation.** { *; }
-keepclasseswithmembers @com.abubusoft.kripton.annotation.BindType class ** { *; }
-keepclasseswithmembers @com.abubusoft.kripton.annotation.BindXml class ** { *; }
-assumenosideeffects class com.abubusoft.kripton.android.Logger { 
    public static void verbose(...);
    public static void info(...);
    public static void warn(...);
    public static void debug(...);
    public static void error(...);
}
-dontwarn com.abubusoft.kripton.androidx.livedata.KriptonXLiveData
-dontwarn com.abubusoft.kripton.androidx.livedata.KriptonXComputableLiveData
-dontwarn com.abubusoft.kripton.androidx.livedata.KriptonXComputableLiveData*

If project uses Retrofit, you need to configure proguard for Retrofit:

##############################
# Retrofit
##############################
-dontwarn retrofit2.**
-dontwarn org.codehaus.mojo.**
-keep class retrofit2.** { *; }
-keepattributes Signature
-keepattributes Exceptions
-keepattributes *Annotation*

#
# https://stackoverflow.com/questions/33047806/proguard-duplicate-definition-of-library-class
#
-dontnote android.net.http.*
-dontnote org.apache.commons.codec.**
-dontnote org.apache.http.**

#
# https://github.com/square/okhttp/issues/3355
#
-dontwarn okio.**
-dontwarn com.squareup.okhttp3.**
-keep class com.squareup.okhttp3.** { *; }
-keep interface com.squareup.okhttp3.* { *; }
-dontwarn javax.annotation.Nullable
-dontwarn javax.annotation.ParametersAreNonnullByDefault

-keepattributes RuntimeVisibleAnnotations
-keepattributes RuntimeInvisibleAnnotations
-keepattributes RuntimeVisibleParameterAnnotations
-keepattributes RuntimeInvisibleParameterAnnotations
-keepattributes EnclosingMethod

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

-keepclasseswithmembers interface * {
    @retrofit2.* <methods>;
}

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

If project uses Glide, you need to configure proguard for Glide:

##############################
# Glide
##############################

-keep class com.abubusoft.kripton.quickstart.network.okhttp3.OkHttpGlideModule { *; }

Table of Contents

Query definition

Features

Relations

Multithread supports

Modularization

Annotations for data convertion

Annotations for SQLite ORM

Annotations for shared preferences

Clone this wiki locally