-
Notifications
You must be signed in to change notification settings - Fork 6
fix(android): process proguard template placeholder before copying #395
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
The Tauri proguard-tauri.pro template file contains `$PACKAGE` placeholder that needs to be substituted with the actual package name before use. The previous code was copying the raw template, which meant the R8/ProGuard rule `-keep class $PACKAGE.TauriActivity` was invalid and didn't match anything, causing TauriActivity and related classes to be stripped. This fixes the v2.0.13 Android app crash on launch issue where the APK was missing critical Kotlin classes (TauriActivity, Ipc, RustWebView, etc.) due to R8 stripping them. Fixes #394 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
📝 WalkthroughWalkthroughGitHub Actions workflows updated to perform placeholder substitution for ProGuard files during Android builds: TAURI_PROGUARD now has Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
Greptile SummaryFixed critical Android build issue where proguard templates were being copied without processing placeholders, causing R8 to strip essential Kotlin classes and resulting in app crashes on launch. Key Changes:
Impact:
Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant CI as GitHub Actions
participant Cargo as Cargo Metadata
participant Templates as Tauri/Wry Templates
participant Sed as sed Processor
participant Gen as Generated Files
participant R8 as R8/ProGuard
CI->>Cargo: cargo metadata (get tauri/wry paths)
Cargo-->>CI: TAURI_DIR, WRY_DIR paths
Note over CI,Templates: Before (Broken in PR #386)
CI->>Templates: Read proguard-tauri.pro
Templates-->>CI: -keep class $PACKAGE.TauriActivity
CI->>Gen: cp (direct copy)
Gen-->>R8: -keep class $PACKAGE.TauriActivity
Note over R8: ❌ R8 can't match literal "$PACKAGE"<br/>strips TauriActivity → crash
Note over CI,R8: After (This Fix)
CI->>Templates: Read proguard-tauri.pro
Templates-->>CI: -keep class $PACKAGE.TauriActivity
CI->>Sed: sed "s/\$PACKAGE/com.opensecret.maple/g"
Sed-->>Gen: -keep class com.opensecret.maple.TauriActivity
Gen-->>R8: -keep class com.opensecret.maple.TauriActivity
Note over R8: ✓ R8 matches & preserves class
CI->>Templates: Read proguard-wry.pro
Templates-->>CI: -keep class {{package-unescaped}}.Ipc
CI->>Sed: sed "s/{{package-unescaped}}/com.opensecret.maple/g"
Sed-->>Gen: -keep class com.opensecret.maple.Ipc
Gen-->>R8: -keep class com.opensecret.maple.Ipc
Note over R8: ✓ R8 matches & preserves class
|
The Wry proguard-wry.pro template also contains placeholders that need
to be substituted. This file was not being copied/generated at all.
The template uses `{{package-unescaped}}` which needs to be replaced
with the actual package name (cloud.opensecret.maple).
Without this, R8 strips the Wry-related classes: Ipc, RustWebView,
RustWebChromeClient, RustWebViewClient, Logger, PermissionHelper, etc.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Deploying maple with
|
| Latest commit: |
5c3b5c0
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://d641fb0a.maple-ca8.pages.dev |
| Branch Preview URL: | https://fix-android-proguard-templat.maple-ca8.pages.dev |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In @.github/workflows/android-build.yml:
- Around line 376-379: The generated WRY proguard rules are being written to the
generated-sources dir ($GEN_KOTLIN_DIR) which is unreliable; instead, write the
processed WRY_PROGUARD output into the app module root (the same location used
for proguard-tauri.pro) so Gradle/R8 can find it. Update the sed redirection
that uses WRY_PROGUARD and PACKAGE to output proguard-wry.pro into the app root
(where proguard-tauri.pro is placed) rather than $GEN_KOTLIN_DIR, keeping the
filename proguard-wry.pro.
| # Wry proguard rules (process {{package-unescaped}} placeholder) | ||
| WRY_PROGUARD="$WRY_DIR/src/android/kotlin/proguard-wry.pro" | ||
| if [ -f "$WRY_PROGUARD" ]; then | ||
| sed "s/{{package-unescaped}}/$PACKAGE/g" "$WRY_PROGUARD" > "$GEN_KOTLIN_DIR/proguard-wry.pro" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
# First, let's verify the Gradle references to proguard-wry.pro
rg -n --glob '*.gradle*' --glob '*.kts' 'proguard-wry\.pro'Repository: OpenSecretCloud/Maple
Length of output: 47
🏁 Script executed:
# Also check for proguardFiles configuration in Gradle
rg -n --glob '*.gradle*' --glob '*.kts' 'proguardFiles'Repository: OpenSecretCloud/Maple
Length of output: 146
🏁 Script executed:
# Let's examine the android-build.yml file to understand GEN_KOTLIN_DIR variable
cat -n .github/workflows/android-build.yml | sed -n '350,385p'Repository: OpenSecretCloud/Maple
Length of output: 1913
🏁 Script executed:
# Find where GEN_KOTLIN_DIR is defined in the workflow
rg -n 'GEN_KOTLIN_DIR=' .github/workflows/android-build.ymlRepository: OpenSecretCloud/Maple
Length of output: 169
🏁 Script executed:
# Examine the Gradle proguardFiles configuration
cat -n frontend/src-tauri/gen/android/app/build.gradle.kts | sed -n '50,65p'Repository: OpenSecretCloud/Maple
Length of output: 642
🏁 Script executed:
# Also check if there's a proguard-wry.pro file anywhere in the codebase
find . -name "proguard-wry.pro" 2>/dev/nullRepository: OpenSecretCloud/Maple
Length of output: 47
🏁 Script executed:
# Check if there are other .pro files in the codebase to understand the pattern
find . -name "*.pro" -type f 2>/dev/nullRepository: OpenSecretCloud/Maple
Length of output: 120
🏁 Script executed:
# Let's also check the context around the Gradle configuration to understand the working directory
cd frontend/src-tauri/gen/android/app && pwdRepository: OpenSecretCloud/Maple
Length of output: 118
Write proguard-wry.pro to the app root directory, consistent with proguard-tauri.pro.
Line 379 writes the file to $GEN_KOTLIN_DIR (generated sources subdirectory), which is unreliable and inconsistent with how proguard-tauri.pro is placed directly in the app root on line 371. Gradle expects ProGuard rules in the app module root for reliable R8 processing.
🔧 Proposed fix
- sed "s/{{package-unescaped}}/$PACKAGE/g" "$WRY_PROGUARD" > "$GEN_KOTLIN_DIR/proguard-wry.pro"
+ sed "s/{{package-unescaped}}/$PACKAGE/g" "$WRY_PROGUARD" > "frontend/src-tauri/gen/android/app/proguard-wry.pro"📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| # Wry proguard rules (process {{package-unescaped}} placeholder) | |
| WRY_PROGUARD="$WRY_DIR/src/android/kotlin/proguard-wry.pro" | |
| if [ -f "$WRY_PROGUARD" ]; then | |
| sed "s/{{package-unescaped}}/$PACKAGE/g" "$WRY_PROGUARD" > "$GEN_KOTLIN_DIR/proguard-wry.pro" | |
| # Wry proguard rules (process {{package-unescaped}} placeholder) | |
| WRY_PROGUARD="$WRY_DIR/src/android/kotlin/proguard-wry.pro" | |
| if [ -f "$WRY_PROGUARD" ]; then | |
| sed "s/{{package-unescaped}}/$PACKAGE/g" "$WRY_PROGUARD" > "frontend/src-tauri/gen/android/app/proguard-wry.pro" |
🤖 Prompt for AI Agents
In @.github/workflows/android-build.yml around lines 376 - 379, The generated
WRY proguard rules are being written to the generated-sources dir
($GEN_KOTLIN_DIR) which is unreliable; instead, write the processed WRY_PROGUARD
output into the app module root (the same location used for proguard-tauri.pro)
so Gradle/R8 can find it. Update the sed redirection that uses WRY_PROGUARD and
PACKAGE to output proguard-wry.pro into the app root (where proguard-tauri.pro
is placed) rather than $GEN_KOTLIN_DIR, keeping the filename proguard-wry.pro.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary
$PACKAGEplaceholder in the Tauri proguard templateRoot Cause
When the Android build pipeline was refactored to parallelize builds (PR #386), the step that copies
proguard-tauri.prowas doing a direct copy without processing the$PACKAGEplaceholder:The Tauri template contains:
This was being copied as-is, so R8 couldn't match the rule and stripped
TauriActivityand all other generated Kotlin classes.Fix
Process the placeholder before copying:
Test plan
Fixes #394
🤖 Generated with Claude Code
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.