From b5a50d8281b79901cede6f9d1efaffeb4e1f7c05 Mon Sep 17 00:00:00 2001 From: Pierre Degand Date: Wed, 16 May 2018 03:34:56 +0200 Subject: [PATCH] Update Proguard configuration for codegen (#542) * Update Proguard configuration for codegen -keepnames will prevent Proguard from renaming the class during obfuscation phase but won't protect the class from code shrinking. In most cases, the generated are never referenced directly in the code as the adapters are loaded dynamically. This means that, for Proguard, the class is unused and it will remove the generated adapters during the shrinking phase. The adapters need to be kept as well as there primary constructor. * Keep fields of generated JsonAdapter --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b2b5ca6..3f34b61 100644 --- a/README.md +++ b/README.md @@ -597,7 +597,10 @@ Additional rules are needed if you are using Kotlin: ``` *...If you are using the codegen API (i.e. `JsonClass(generateAdapter = true)`):* ``` --keepnames class **JsonAdapter +-keep class **JsonAdapter { + (...); + ; +} -keepnames @com.squareup.moshi.JsonClass class * ```