Use Proguard
Use Proguard
Proguard is an advanced and powerful
tool for Android developers. Starting with version 2.0.0 of the Support SDK we include
consumer-proguard.pro
files to our artifacts, which are Proguard configurations that are
applied automatically when Proguard is used on your app. This should remove the need for custom Proguard rules for the SDKs.
These rules are guidelines only and some projects require more to work. You can modify those rules and adapt them to your project, but be aware that we do not support custom rules. Any issue that could be associated with proguard should be reproduced with the default set of rules, present in our demo apps.
For reference, here are the contents of our consumer-proguard.pro
files for the Support SDK:
# Core SDK
-keep class zendesk.core.** { *; }
# 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
# Support SDK
-keepnames class zendesk.support.** { *; }
# 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 { *; }
R8
As noted in our known issues, the R8 compiler is overly aggressive in its code optimisations, and removes some code that the Support SDK requires to function correctly. If using the R8 compiler, please add the following rules to your Proguard file:
# Guide Main Screen
-keep class zendesk.support.HelpCenterSettings { *; }
-keep class zendesk.support.HelpResponse { *; }
-keep class zendesk.support.ArticlesListResponse { *; }
-keep class zendesk.support.CategoryItem { *; }
-keep class zendesk.support.SectionItem { *; }
-keep class zendesk.support.ArticleItem { *; }
-keep class zendesk.support.SeeAllArticlesItem { *; }
-keep class zendesk.support.guide.HelpCenterActivity { *; }
# Guide Search Results
-keep class zendesk.support.guide.HelpSearchFragment { *; }
-keep class zendesk.support.ArticlesSearchResponse { *; }
-keep class zendesk.support.SearchArticle { *; }
-keep class zendesk.support.guide.HelpSearchRecyclerViewAdapter { *; }
-keep class zendesk.support.HelpCenterSearch { *; }
-keep class zendesk.support.Category { *; }
-keep class zendesk.support.Section { *; }
-keep class zendesk.support.Article { *; }
# Guide View Article
-keep class zendesk.support.guide.ArticleViewModel { *; }
-keep class zendesk.support.guide.ArticleConfiguration { *; }
-keep class zendesk.support.guide.ViewArticleActivity { *; }
-keep class zendesk.support.ArticleResponse { *; }
-keep class zendesk.support.ArticleVote { *; }
-keep class zendesk.support.ArticleVoteResponse { *; }
-keep class zendesk.support.ZendeskArticleVoteStorage { *; }
-keep class zendesk.support.AttachmentResponse { *; }
-keep class zendesk.support.HelpCenterAttachment { *; }
# Support Requests (Create, Update, List)
-keep class zendesk.support.request.** { *; }
-keep class zendesk.support.requestlist.** { *; }
-keep class zendesk.support.SupportSdkSettings { *; }
-keep class zendesk.support.Request { *; }
-keep class zendesk.support.CreateRequest { *; }
-keep class zendesk.support.Comment { *; }
-keep class zendesk.support.CommentResponse { *; }
-keep class zendesk.support.CommentsResponse { *; }
-keep class zendesk.support.EndUserComment { *; }
-keep class zendesk.support.ZendeskRequestStorage { *; }
-keep class zendesk.support.ZendeskRequestProvider { *; }
-keep class zendesk.support.CreateRequestWrapper { *; }
-keep class zendesk.support.UpdateRequestWrapper { *; }
-keep class zendesk.support.RequestsResponse { *; }
-keep class zendesk.support.RequestResponse { *; }
# Support Attachments
-keep class zendesk.support.UploadResponse { *; }
-keep class zendesk.support.UploadResponseWrapper { *; }
-keep class zendesk.support.ZendeskUploadProvider { *; }
-keep class zendesk.support.Attachment { *; }