Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
lucyAlvin's avatar
lucyAlvin
Honored Guest
4 months ago
Solved

Keep Rules in Proguard Files (Using R8 Minify)

I'm developing an Immersive App for Meta Quest using the Meta Spatial SDK in Android Studio with R8 minification enabled. When building a signed APK, I encounter the following error:

Missing classes detected while running R8. Please add the missing classes or apply additional keep rules that are generated in D:\AndroidProject\[package-name]\app\build\outputs\mapping\questRelease\missing_rules.txt.

Missing class horizonos.app.container.TaskContainer (referenced from: horizonos.app.container.TaskContainer com.meta.spatial.runtime.PanelDisplay.taskContainer and 4 other contexts)

Missing class horizonos.app.container.TaskContainerManager$TaskContainerCallback (referenced from: horizonos.app.container.TaskContainer com.meta.spatial.runtime.PanelDisplay.tryGetTaskContainer(android.content.Context, android.content.Context) and 2 other contexts)

Missing class horizonos.app.container.TaskContainerManager (referenced from: horizonos.app.container.TaskContainer com.meta.spatial.runtime.PanelDisplay.tryGetTaskContainer(android.content.Context, android.content.Context))

Missing class vros.os.VrosBuild (referenced from: horizonos.app.container.TaskContainer com.meta.spatial.runtime.PanelDisplay.tryGetTaskContainer(android.content.Context, android.content.Context))

The missing_rules.txt file suggests adding the following rules to proguard-rules.pro:

# Please add these rules to your existing keep rules in order to suppress warnings.

# This is generated automatically by the Android Gradle plugin.

-dontwarn horizonos.app.container.TaskContainer

-dontwarn horizonos.app.container.TaskContainerManager$TaskContainerCallback

-dontwarn horizonos.app.container.TaskContainerManager

-dontwarn vros.os.VrosBuild

When I add these -dontwarn rules to proguard-rules.pro, the signed APK builds successfully. However, when I deploy and launch the APK on a Meta Quest device, the app gets stuck in a loading state and eventually shows a "Not Responding" error after some time.

I’ve also tried the following keep rules in proguard-rules.pro, but they prevent the APK from building:

-keep class horizonos.** { *; }

-keep class vros.** { *; }

-keep class com.meta.spatial.** { *; }

My question: What specific keep rules should I use in proguard-rules.pro to ensure that the necessary classes are preserved, allowing the app to build successfully and load properly on Meta Quest without getting stuck in the loading state?

  • I found that adding the following lines to proguard-rules.pro allows the app to work correctly:

    -keep class com.meta.spatial.** { *; }
    -dontwarn horizonos.app.container.TaskContainer
    -dontwarn horizonos.app.container.TaskContainerManager$TaskContainerCallback
    -dontwarn horizonos.app.container.TaskContainerManager
    -dontwarn vros.os.VrosBuild

2 Replies

Replies have been turned off for this discussion
  • Anonymous's avatar
    Anonymous

    Thanks for coming back and sharing your solution!

  • AlvinLu's avatar
    AlvinLu
    Honored Guest

    I found that adding the following lines to proguard-rules.pro allows the app to work correctly:

    -keep class com.meta.spatial.** { *; }
    -dontwarn horizonos.app.container.TaskContainer
    -dontwarn horizonos.app.container.TaskContainerManager$TaskContainerCallback
    -dontwarn horizonos.app.container.TaskContainerManager
    -dontwarn vros.os.VrosBuild