Skip to content

Commit eb4f5c7

Browse files
graycreateclaude
andcommitted
feat: enable R8 minification and upload ReTrace mapping files
- Enable minifyEnabled and shrinkResources for release builds - Update ProGuard rules with comprehensive library support - Add rules for Dagger2, ButterKnife, RxJava2, Fruit, and other libraries - Keep essential classes (BuildConfig, R, data models) but allow code obfuscation - Use proguard-android-optimize.txt for better optimization This will: - Generate mapping.txt file for crash deobfuscation - Reduce APK/AAB size through code shrinking - Improve app security through code obfuscation - Enable upload of ReTrace mapping files to Google Play Console 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent d9354da commit eb4f5c7

File tree

2 files changed

+109
-4
lines changed

2 files changed

+109
-4
lines changed

app/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ android {
3737
}
3838

3939
release {
40-
minifyEnabled false // False for fix of a lot crash in release
41-
// shrinkResources true
42-
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
40+
minifyEnabled true
41+
shrinkResources true
42+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
4343
signingConfig signingConfigs.release
4444
versionNameSuffix rootProject.ext.app.betaSuffix
4545
}

app/proguard-rules.pro

Lines changed: 106 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,4 +133,109 @@
133133
-keep,allowobfuscation,allowshrinking class io.reactivex.rxjava3.core.Flowable
134134
-keep,allowobfuscation,allowshrinking class io.reactivex.rxjava3.core.Maybe
135135
-keep,allowobfuscation,allowshrinking class io.reactivex.rxjava3.core.Observable
136-
-keep,allowobfuscation,allowshrinking class io.reactivex.rxjava3.core.Single
136+
-keep,allowobfuscation,allowshrinking class io.reactivex.rxjava3.core.Single
137+
138+
#----------------- Additional Rules for V2er App ------------------------
139+
140+
# Keep RxJava2 (current version used in app)
141+
-keep class io.reactivex.** { *; }
142+
-keep interface io.reactivex.** { *; }
143+
-dontwarn io.reactivex.**
144+
145+
# Dagger 2 rules
146+
-dontwarn com.google.errorprone.annotations.**
147+
-keep class dagger.** { *; }
148+
-keep class javax.inject.** { *; }
149+
-keep class * extends dagger.Module
150+
-keep class * extends dagger.Component
151+
-keep @dagger.Component class *
152+
-keep @dagger.Module class * { *; }
153+
-keep @dagger.Provides class * { *; }
154+
-keep @javax.inject.Inject class * { *; }
155+
156+
# ButterKnife rules
157+
-keep class butterknife.** { *; }
158+
-dontwarn butterknife.internal.**
159+
-keep class **$$ViewBinder { *; }
160+
-keepclasseswithmembernames class * {
161+
@butterknife.* <fields>;
162+
}
163+
-keepclasseswithmembernames class * {
164+
@butterknife.* <methods>;
165+
}
166+
167+
# Custom Fruit HTML parsing library
168+
-keep class me.ghui.fruit.** { *; }
169+
-dontwarn me.ghui.fruit.**
170+
-keep @me.ghui.fruit.annotations.* class * { *; }
171+
-keepclasseswithmembernames class * {
172+
@me.ghui.fruit.annotations.* <methods>;
173+
}
174+
-keepclasseswithmembernames class * {
175+
@me.ghui.fruit.annotations.* <fields>;
176+
}
177+
178+
# RxLifecycle
179+
-keep class com.trello.rxlifecycle2.** { *; }
180+
-dontwarn com.trello.rxlifecycle2.**
181+
182+
# Logger library
183+
-keep class com.orhanobut.logger.** { *; }
184+
-dontwarn com.orhanobut.logger.**
185+
186+
# Flurry Analytics (referenced in CLAUDE.md)
187+
-keep class com.flurry.** { *; }
188+
-dontwarn com.flurry.**
189+
190+
# Sentry (referenced in CLAUDE.md)
191+
-keep class io.sentry.** { *; }
192+
-dontwarn io.sentry.**
193+
194+
# Keep only essential application classes (allow most classes to be obfuscated)
195+
-keep class me.ghui.v2er.BuildConfig { *; }
196+
-keep class me.ghui.v2er.R { *; }
197+
-keep class me.ghui.v2er.R$* { *; }
198+
199+
# Keep Application class and Activities (required by Android)
200+
-keep class me.ghui.v2er.Application { *; }
201+
-keep class * extends android.app.Application { *; }
202+
203+
# Keep data models used for JSON parsing (Gson/Fruit)
204+
-keep class me.ghui.v2er.network.bean.** { *; }
205+
206+
# Keep classes with native methods
207+
-keepclasseswithmembernames class * {
208+
native <methods>;
209+
}
210+
211+
# Keep all Activities, Services, BroadcastReceivers
212+
-keep public class * extends android.app.Activity
213+
-keep public class * extends android.app.Service
214+
-keep public class * extends android.content.BroadcastReceiver
215+
-keep public class * extends android.content.ContentProvider
216+
217+
# Keep view constructors (for layout inflation)
218+
-keepclasseswithmembers class * {
219+
public <init>(android.content.Context, android.util.AttributeSet);
220+
}
221+
-keepclasseswithmembers class * {
222+
public <init>(android.content.Context, android.util.AttributeSet, int);
223+
}
224+
225+
# Keep custom views and their constructors
226+
-keep public class * extends android.view.View {
227+
public <init>(android.content.Context);
228+
public <init>(android.content.Context, android.util.AttributeSet);
229+
public <init>(android.content.Context, android.util.AttributeSet, int);
230+
}
231+
232+
# Keep Parcelable implementations
233+
-keepclassmembers class * implements android.os.Parcelable {
234+
public static final android.os.Parcelable$Creator CREATOR;
235+
}
236+
237+
# Keep enums
238+
-keepclassmembers enum * {
239+
public static **[] values();
240+
public static ** valueOf(java.lang.String);
241+
}

0 commit comments

Comments
 (0)