Skip to content

Conversation

@graycreate
Copy link
Member

Summary

  • Enable R8 minification (minifyEnabled true) and resource shrinking for release builds
  • Add comprehensive ProGuard rules for all project dependencies
  • Configure proper obfuscation while preserving essential classes

Changes Made

Build Configuration (app/build.gradle)

  • ✅ Enable minifyEnabled true (was false)
  • ✅ Enable shrinkResources true for additional size reduction
  • ✅ Use proguard-android-optimize.txt for better optimization

ProGuard Rules (app/proguard-rules.pro)

  • ✅ Add rules for Dagger 2 dependency injection
  • ✅ Add rules for ButterKnife view binding
  • ✅ Add rules for RxJava2 reactive programming
  • ✅ Add rules for custom Fruit HTML parsing library
  • ✅ Add rules for RxLifecycle, Logger, analytics libraries
  • ✅ Keep data models (network.bean.**) for JSON parsing
  • ✅ Keep essential Android classes (Activities, Services, etc.)
  • ✅ Allow application classes to be obfuscated while preserving functionality

Benefits

🎯 ReTrace Mapping Files: Enables crash deobfuscation in Google Play Console
📦 Smaller APK Size: Code and resource shrinking reduces app size
🔒 Enhanced Security: Code obfuscation makes reverse engineering harder
🚀 Better Performance: R8 optimizations can improve runtime performance

Testing

  • ✅ Local debug build succeeds
  • ✅ Release minification completes successfully
  • ✅ Mapping files generated: mapping.txt, seeds.txt, usage.txt
  • ✅ Essential classes preserved, application classes properly obfuscated
  • ✅ All ProGuard rules validated for project dependencies

Validation Steps

Once merged, the next release will:

  1. Generate mapping files during build process
  2. Upload ReTrace mapping to Google Play Console automatically
  3. Enable proper crash stack trace deobfuscation

🤖 Generated with Claude Code

- 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]>
Copilot AI review requested due to automatic review settings September 9, 2025 10:53
@graycreate graycreate merged commit f750cda into main Sep 9, 2025
4 checks passed
@graycreate graycreate deleted the feature/enable-proguard-minification branch September 9, 2025 10:53
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enables R8 minification and resource shrinking for release builds, which was previously disabled due to crashes. The change includes comprehensive ProGuard rules to properly handle obfuscation while preserving essential classes and functionality.

  • Enable R8 minification and resource shrinking for release builds
  • Add extensive ProGuard rules for all project dependencies (Dagger 2, ButterKnife, RxJava2, etc.)
  • Configure proper obfuscation while preserving critical Android components and data models

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
app/build.gradle Enable minification, resource shrinking, and switch to optimized ProGuard configuration
app/proguard-rules.pro Add comprehensive ProGuard rules for all project dependencies and Android components

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +141 to +142
-keep class io.reactivex.** { *; }
-keep interface io.reactivex.** { *; }
Copy link

Copilot AI Sep 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These broad RxJava2 rules conflict with the existing specific RxJava3 rules (lines 134-136) and are overly permissive. The existing rules already handle RxJava properly with selective obfuscation. Consider removing these duplicate rules or being more specific about which RxJava2 classes need preservation.

Suggested change
-keep class io.reactivex.** { *; }
-keep interface io.reactivex.** { *; }
-keep,allowobfuscation,allowshrinking class io.reactivex.Flowable
-keep,allowobfuscation,allowshrinking class io.reactivex.Maybe
-keep,allowobfuscation,allowshrinking class io.reactivex.Observable
-keep,allowobfuscation,allowshrinking class io.reactivex.Single

Copilot uses AI. Check for mistakes.

# Dagger 2 rules
-dontwarn com.google.errorprone.annotations.**
-keep class dagger.** { *; }
Copy link

Copilot AI Sep 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This rule is overly broad and prevents any obfuscation of Dagger classes. Consider using more specific rules that only keep the essential Dagger classes while allowing others to be obfuscated, such as -keep class dagger.Module and -keep class dagger.Component only.

Suggested change
-keep class dagger.** { *; }

Copilot uses AI. Check for mistakes.
-keep @javax.inject.Inject class * { *; }

# ButterKnife rules
-keep class butterknife.** { *; }
Copy link

Copilot AI Sep 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This rule is overly broad for ButterKnife. The subsequent specific rules (lines 159-165) should be sufficient to handle ButterKnife's annotation processing. Consider removing this blanket rule to allow better obfuscation of ButterKnife internals.

Suggested change
-keep class butterknife.** { *; }

Copilot uses AI. Check for mistakes.
}

# Custom Fruit HTML parsing library
-keep class me.ghui.fruit.** { *; }
Copy link

Copilot AI Sep 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This rule prevents all obfuscation of the Fruit library. The annotation-specific rules (lines 170-176) should be sufficient for proper functionality. Consider removing this blanket rule to allow obfuscation of non-essential Fruit classes.

Suggested change
-keep class me.ghui.fruit.** { *; }

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants