ionic-team / ionic-team/capacitor

[Bug]: App crashes on Android when minifyEnabled true

Open
#8,587 1 comment 1 reaction 0 assignees View on GitHub
triage
Dominant language
TypeScript
Stars
16.7k
Forks
1.3k
Avg merge
3d 15h
Merged PRs (30d)
10

Description

### Capacitor Version

Capacitor Doctor 💊

Latest Dependencies:

@capacitor/cli: 8.5.1
@capacitor/core: 8.5.1
@capacitor/android: 8.5.1
@capacitor/ios: 8.5.1

Installed Dependencies:

@capacitor/cli: 8.5.1
@capacitor/android: 8.5.1
@capacitor/core: 8.5.1
@capacitor/ios: 8.5.1

[success] iOS looking great! 👌
[success] Android looking great! 👌

### Other API Details

```Shell
npm: 11.13.0
node: v24.16.0
```

### Platforms Affected

- [ ] iOS
- [x] Android
- [ ] Web

### Current Behavior

Plugins crashes on production builds when obfuscation is enabled, which is now required for feb 2027.

### Expected Behavior

No crashes

### Project Reproduction

https://github.com/IsraelHikingMap/Site/tree/main/IsraelHiking.Web

### Additional Information

I've played around with it and the following rules have solved it:
For all related plugin that uses permissions:
```
-keep @interface com.getcapacitor.**
```

The following is needed for the camera plugin, let me know if you want me to open a different issue:
```
# The camera plugin carries its parameters and its results between the app and the editor as gson
# objects, and neither gson nor the ioncamera-android library that uses it ships rules of its own.
# Gson works over these classes by reflection: it needs the fields to still be there to fill them,
# the @SerializedName on each one to know which json key it answers to, and the generic signature
# of a TypeToken to know what it is building - none of which R8 can see is used. These are gson's
# own documented rules.
-keepattributes Signature
-dontwarn sun.misc.**
-keepclassmembers,allowobfuscation class * {
@com.google.gson.annotations.SerializedName ;
}
-keep,allowobfuscation,allowshrinking class com.google.gson.reflect.TypeToken
-keep,allowobfuscation,allowshrinking class * extends com.google.gson.reflect.TypeToken
-keep class * extends com.google.gson.TypeAdapter
-keep class * implements com.google.gson.TypeAdapterFactory
-keep class * implements com.google.gson.JsonSerializer
-keep class * implements com.google.gson.JsonDeserializer
```

If there's more information you'd like me to check please let me know.

Contributor guide

Open the contributing guide

Research direction

Use the IsraelHiking.Web reproduction project to build the Android production variant with minifyEnabled true, then compare the crash with the listed permission and camera Gson keep rules. The payload names no repository files or tests; done means the production Android build no longer crashes when obfuscation is enabled.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.