Bugfix/minification proguard missing symbols#734
Conversation
There was a problem hiding this comment.
Pull request overview
Updates the example Android app and Millicast documentation to address a crash seen when enabling minification (missing Kotlin classes at runtime).
Changes:
- Add a ProGuard/R8 keep rule for
kotlin.*to the example app. - Enable minification for example Android release builds by default.
- Document the required keep rule in
doc/millicast.md.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| example/android/app/proguard-rules.pro | Adds a keep rule intended to prevent Kotlin classes from being stripped during minification. |
| example/android/app/build.gradle | Enables ProGuard/R8 minification for release builds in the example app. |
| doc/millicast.md | Documents the Android minification note and keep rule for Millicast integration. |
|
|
||
| # Add any project specific keep options here: | ||
|
|
||
| -keep class kotlin.** { *; } |
There was a problem hiding this comment.
-keep class kotlin.** { *; } disables shrinking/obfuscation for the entire Kotlin stdlib, which can significantly reduce the benefit of enabling minification (larger APK/AAB). Consider narrowing this rule to only the specific Kotlin classes that are reflectively/JNI-referenced (e.g., the unsigned types involved in the crash) so release builds still get meaningful shrinking.
| -keep class kotlin.** { *; } | |
| # Keep only specific Kotlin stdlib classes that are reflectively/JNI-referenced | |
| -keep class kotlin.UInt { *; } | |
| -keep class kotlin.ULong { *; } | |
| -keep class kotlin.UByte { *; } | |
| -keep class kotlin.UShort { *; } |
| When adding the Millicast integration into your android project, make sure to add the following keep rule in your `proguard-rules.pro` file: | ||
| ``` | ||
| -keep class kotlin.** { *; } | ||
| ``` | ||
|
|
||
| Otherwise, you will encounter a `ClassNotFoundException` when attempting to run the application. | ||
|
|
There was a problem hiding this comment.
This documentation asks integrators to manually add a ProGuard/R8 keep rule, but the library already publishes consumer rules via consumerProguardFiles (see android/build.gradle). To prevent production crashes when minification is enabled, consider shipping the necessary keep rule(s) in the library’s consumer ProGuard file instead of relying on every app to add a manual rule.
| When adding the Millicast integration into your android project, make sure to add the following keep rule in your `proguard-rules.pro` file: | |
| ``` | |
| -keep class kotlin.** { *; } | |
| ``` | |
| Otherwise, you will encounter a `ClassNotFoundException` when attempting to run the application. | |
| The Millicast integration ships its required ProGuard/R8 keep rules via the library's `consumerProguardFiles` configuration. | |
| In a typical setup, no additional ProGuard/R8 rules are needed to use Millicast with minification enabled. | |
| If you use a heavily customized ProGuard/R8 configuration, ensure that the consumer rules from the library are not being overridden or removed, otherwise you may encounter `ClassNotFoundException` errors at runtime. |
There was a problem hiding this comment.
@Yousif-CS wouldn't it make more sense to add the R8 rules to the Millicast's consumer rules as is suggested here? Otherwise all Millicast SDK customers will have to include these rules I guess?
There was a problem hiding this comment.
I think we can, though from what I've seen in the docs it needs to be added at the app level? Let me try that.
|
|
||
| ## Note on minification on Android | ||
|
|
||
| When adding the Millicast integration into your android project, make sure to add the following keep rule in your `proguard-rules.pro` file: |
There was a problem hiding this comment.
Capitalize “Android” for consistency with the rest of the docs ("your Android project").
| When adding the Millicast integration into your android project, make sure to add the following keep rule in your `proguard-rules.pro` file: | |
| When adding the Millicast integration into your Android project, make sure to add the following keep rule in your `proguard-rules.pro` file: |
|
@tvanlaerhoven we won't need this anymore, we have already added this pro guard rule in Millicast SDK 2.5.3 And updated THEOplayer version 10.11 with it. We won't need this anymore, closing. |
A customer ran into an issue when enabling minification and encountered the following crash:
This requires integrating applications to add a keep rule for
kotlin.*classes in their proguard file. This PR introduces it for the example application, enables minification for release builds by default and also adds a note in the documentation.