Skip to content

Please provide consumer proguard rules for R8/Proguard on Android #6392

Open

Description

@AlexanderGH

MediaPipe Solution (you are using)

No response

Programming language

No response

Are you willing to contribute it

No response

Describe the feature and the current behaviour/state

Currently, everyone using mediapipe on android is copy pasting some terribly inefficient -keep rules to support R8. Mediapipe should use Android's keep annotations and/or fine-grained minimal keep rules (including using proper aar deps for things like flogger, and protobuf to their own consumer proguared rules are pulled via maven).

Will this change the current API? How?

No

Who will benefit with this feature?

All android users of mediapipe.

Please specify the use cases for this feature

Android apps

Any Other info

"Describe the feature and the current behaviour/state" in this template should be turned into a multiline text field instead of one line. Same for this text box and most of the others.

Activity

  1. added
    type:featureEnhancement in the New Functionality or Request for a New Solution
    on Oct 29, 2026
  2. akashvverma1995 commented on Nov 2, 2026

    @akashvverma1995

    Hi @AlexanderGH

    Thank you for raising this feature request. I'll look into it and get back to you with an updates.

  3. ryank311 commented on Nov 2, 2026

    @ryank311

    +1 To this issue. We are using Proguard/Dexguard as well and its difficult to know if the rules need to change/update as new versions of MediaPipe are released. Our rules currently look something like the snippet below and the ** rules are not ideal.

    # MediaPipe references generated proto classes that its published AAR does not contain.
    -dontwarn com.google.mediapipe.proto.CalculatorProfileProto$CalculatorProfile
    -dontwarn com.google.mediapipe.proto.GraphTemplateProto$CalculatorGraphTemplate
    
    # MediaPipe 1.1.0 declares LiteRT-LM as an optional Maven dependency. Only ImageEmbedder's LiteRT-LM
    # executor references it, and ImageEmbedder probes for it with Class.forName before using it.
    -dontwarn com.google.ai.edge.litertlm.**
    
    # MediaPipe (as of 1.1.0) does not publish consumer rules even though its Java/JNI boundary resolves
    # framework and task classes by name. Keep that dependency boundary intact in optimized builds.
    -keep class com.google.mediapipe.** { *; }
    
    # Flogger discovers logger and call-site identity from live stack frames. Renaming, inlining, or
    # removing those frames breaks MediaPipe's Graph class initialization in optimized builds.
    -keep class com.google.common.flogger.** { *; }
    
    # The protobuf full runtime loads DescriptorMessageInfoFactory by its original name and uses it to
    # reflect over messages such as Any while MediaPipe serializes calculator graph configuration.
    -keep class com.google.protobuf.** { *; }
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

platform:androidIssues with Android as Platformtype:featureEnhancement in the New Functionality or Request for a New Solution

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions