Skip to content

Conversation

@Yousif-CS
Copy link
Contributor

A customer ran into an issue when enabling minification and encountered the following crash:

No pending exception expected: java.lang.ClassNotFoundException: kotlin.ULong 
  at java.lang.String java.lang.Runtime.nativeLoad(java.lang.String, java.lang.ClassLoader, java.lang.Class) (Runtime.java:-2) 
  at void java.lang.Runtime.loadLibrary0(java.lang.ClassLoader, java.lang.Class, java.lang.String) (Runtime.java:1095) 
  at void java.lang.Runtime.loadLibrary0(java.lang.Class, java.lang.String) (Runtime.java:1019) 
  at void java.lang.System.loadLibrary(java.lang.String) (System.java:1765) at void com.millicast.Core.initialize() (SourceFile:14) 
  at void com.theoplayer.android.internal.millicast.b.<clinit>() (SourceFile:9) at

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.

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

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.** { *; }
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

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

-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.

Suggested change
-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 { *; }

Copilot uses AI. Check for mistakes.
Comment on lines +52 to +58
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.

Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
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.

Copilot uses AI. Check for mistakes.
Copy link
Member

Choose a reason for hiding this comment

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

@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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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:
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

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

Capitalize “Android” for consistency with the rest of the docs ("your Android project").

Suggested change
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:

Copilot uses AI. Check for mistakes.
@tvanlaerhoven tvanlaerhoven added the bug Something isn't working label Jan 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants