diff --git a/moshi-kotlin-codegen/src/main/java/com/squareup/moshi/kotlin/codegen/api/ProguardRules.kt b/moshi-kotlin-codegen/src/main/java/com/squareup/moshi/kotlin/codegen/api/ProguardRules.kt index 4331c1d..b7cfb36 100644 --- a/moshi-kotlin-codegen/src/main/java/com/squareup/moshi/kotlin/codegen/api/ProguardRules.kt +++ b/moshi-kotlin-codegen/src/main/java/com/squareup/moshi/kotlin/codegen/api/ProguardRules.kt @@ -62,9 +62,23 @@ public data class ProguardConfig( if (!dontKeepClassNames) appendLine("-keepnames class $targetName") - // Keep the `JsonClass` annotation on the target class, R8 will shrink it away otherwise. + // Keep the `JsonClass` annotation on the target class, R8 will strip it away otherwise. appendLine("-keep${if (dontKeepClassNames) ",allowobfuscation" else ""} @com.squareup.moshi.JsonClass class *") + // + // -keepclassmembers enum * { + // public static **[] values(); + // public static ** valueOf(java.lang.String); + // public static ; + // } + // + // Keep the enum values method, R8 will strip it away otherwise. + appendLine("-keepclassmembers enum * {") + appendLine(" public static **[] values();") + appendLine(" public static ** valueOf(java.lang.String);") + appendLine(" public static ;") + appendLine("}") + appendLine("-if class $targetName") appendLine("-${if (dontKeepClassNames) "keepclassmembers" else "keep"} class $adapterCanonicalName {") // Keep the constructor for Moshi's reflective lookup