Minifying your app

Google recommends that you shrink, obfuscate, and optimize your app using the R8 compiler with the Android Gradle plugin.

The Messaging, Support, and Answer Bot SDKs include consumer-proguard.pro files in their artifacts. These files are Proguard configurations that are applied automatically to the SDK libraries when Proguard (or R8) is used on your app. This should remove the need for custom Proguard rules for your SDKs.

On some versions of the Android Gradle plugin, the R8 compiler behaves overly aggressively and removes some classes that are necessary for the proper functioning of the SDKs. The Zendesk SDKs include specific keep rules for these classes where we've found such issues. If you find that these rules aren't sufficient, please let us know at [email protected]

For reference, here are the contents of our consumer-proguard.pro files for the Unified SDK, Support SDK, and Answer Bot SDK:

-keepnames class zendesk.messaging.** { *; }
-keepnames class zendesk.core.** { *; }

-keep class zendesk.core.AuthenticationRequestWrapper { *; }
-keep class zendesk.core.PushRegistrationRequestWrapper { *; }
-keep class zendesk.core.PushRegistrationRequest { *; }
-keep class zendesk.core.PushRegistrationResponse { *; }
-keep class zendesk.core.ApiAnonymousIdentity { *; }

# Gson
-keep class sun.misc.Unsafe { *; }

# Okio
-dontwarn okio.**

# Retrofit
-dontwarn retrofit2.Platform**

# Dagger
-dontwarn com.google.errorprone.annotations.CanIgnoreReturnValue

# OkHttp3: https://github.com/square/okhttp/blob/master/okhttp/src/main/resources/META-INF/proguard/okhttp3.pro
## JSR 305 annotations are for embedding nullability information.
-dontwarn javax.annotation.**

## A resource is loaded with a relative path so the package of this class must be preserved.
-keepnames class okhttp3.internal.publicsuffix.PublicSuffixDatabase

## Animal Sniffer compileOnly dependency to ensure APIs are compatible with older versions of Java.
-dontwarn org.codehaus.mojo.animal_sniffer.*

## OkHttp platform used only on JVM and when Conscrypt dependency is available.
-dontwarn okhttp3.internal.platform.ConscryptPlatform
-keepnames class zendesk.support.** { *; }

-keep class zendesk.support.Comment { *; }
-keep class zendesk.support.CreateRequest { *; }
-keep class zendesk.support.CreateRequestWrapper { *; }
-keep class zendesk.support.EndUserComment { *; }
-keep class zendesk.support.Request { *; }
-keep class zendesk.support.UpdateRequestWrapper { *; }

# Gson
-keep class sun.misc.Unsafe { *; }

# Okio
-dontwarn okio.**

# Retrofit
-dontwarn retrofit2.Platform**

# java-common
-dontwarn java.awt.Color

# Dagger
-dontwarn com.google.errorprone.annotations.*

#Picasso
-dontwarn com.squareup.okhttp.**

# MenuItems
-keep class android.support.v7.widget.SearchView { *; }
-keep class zendesk.support.request.ViewCellAttachmentMenuItem { *; }
-keep class zendesk.answerbot.AnswerBotSettings { *; }

-keepnames class zendesk.answerbot.** { *; }
-keep class zendesk.answerbot.Deflection { *; }

# Gson
-keep class sun.misc.Unsafe { *; }

# Okio
-dontwarn okio.**

# Retrofit
-dontwarn retrofit2.Platform**

# java-common
-dontwarn java.awt.Color

# Dagger
-dontwarn com.google.errorprone.annotations.*