skip to Main Content

When I build an APK it comes out to be 30MB. I recently upgraded to AGP 8.1 from 7.4, not sure if that screwed up something. The Task :app:minifyReleaseWithR8 FAILED fails. The short message is:

Missing classes detected while running R8. Please add the missing classes or apply additional keep rules that are generated in /home/csaba/repos/flutter/track_my_indoor_exercise/build/app/outputs/mapping/release/missing_rules.txt.

The referenced file contains:

# Please add these rules to your existing keep rules in order to suppress warnings.
# This is generated automatically by the Android Gradle plugin.
-dontwarn com.google.android.play.core.splitcompat.SplitCompatApplication
-dontwarn com.google.android.play.core.splitinstall.SplitInstallException
-dontwarn com.google.android.play.core.splitinstall.SplitInstallManager
-dontwarn com.google.android.play.core.splitinstall.SplitInstallManagerFactory
-dontwarn com.google.android.play.core.splitinstall.SplitInstallRequest$Builder
-dontwarn com.google.android.play.core.splitinstall.SplitInstallRequest
-dontwarn com.google.android.play.core.splitinstall.SplitInstallSessionState
-dontwarn com.google.android.play.core.splitinstall.SplitInstallStateUpdatedListener
-dontwarn com.google.android.play.core.tasks.OnFailureListener
-dontwarn com.google.android.play.core.tasks.OnSuccessListener
-dontwarn com.google.android.play.core.tasks.Task

I tried to add

-keep class com.google.android.play.core.splitcompat.** { *; }
-keepclassmembernames class com.google.android.play.core.splitcompat.** { *; }
-keepclassmembers class com.google.android.play.core.splitcompat.** { *; }
-keep class com.google.android.play.core.splitinstall.** { *; }
-keepclassmembernames class com.google.android.play.core.splitinstall.** { *; }
-keepclassmembers class com.google.android.play.core.splitinstall.** { *; }
-keep class com.google.android.play.core.tasks.** { *; }
-keepclassmembernames class com.google.android.play.core.tasks.** { *; }
-keepclassmembers class com.google.android.play.core.tasks.** { *; }

into my ProGuard, and then even tried to add

-keep class com.google.android.play.core.splitcompat.SplitCompatApplication
-keep class com.google.android.play.core.splitinstall.SplitInstallException
-keep class com.google.android.play.core.splitinstall.SplitInstallManager
-keep class com.google.android.play.core.splitinstall.SplitInstallManagerFactory
-keep class com.google.android.play.core.splitinstall.SplitInstallRequest$Builder
-keep class com.google.android.play.core.splitinstall.SplitInstallRequest
-keep class com.google.android.play.core.splitinstall.SplitInstallSessionState
-keep class com.google.android.play.core.splitinstall.SplitInstallStateUpdatedListener
-keep class com.google.android.play.core.tasks.OnFailureListener
-keep class com.google.android.play.core.tasks.OnSuccessListener
-keep class com.google.android.play.core.tasks.Task

But the same classes reported missing still. It’s like the ProGuard file is ignored or something.

The longer task error:

> Task :app:minifyReleaseWithR8 FAILED
AGPBI: {"kind":"error","text":"Missing classes detected while running R8. Please add the missing classes or apply additional keep rules that are generated in /home/csaba/repos/flutter/track_my_indoor_exercise/build/app/outputs/mapping/release/missing_rules.txt.","sources":[{}]}
AGPBI: {"kind":"error","text":"Missing class com.google.android.play.core.splitcompat.SplitCompatApplication (referenced from: void io.flutter.app.FlutterPlayStoreSplitApplication.<init>() and 5 other contexts)nMissing class com.google.android.play.core.splitinstall.SplitInstallException (referenced from: void io.flutter.embedding.engine.deferredcomponents.PlayStoreDeferredComponentManager.lambda$installDeferredComponent$1(int, java.lang.String, java.lang.Exception))nMissing class com.google.android.play.core.splitinstall.SplitInstallManager (referenced from: com.google.android.play.core.splitinstall.SplitInstallManager io.flutter.embedding.engine.deferredcomponents.PlayStoreDeferredComponentManager.splitInstallManager and 5 other contexts)nMissing class com.google.android.play.core.splitinstall.SplitInstallManagerFactory (referenced from: void io.flutter.embedding.engine.deferredcomponents.PlayStoreDeferredComponentManager.<init>(android.content.Context, io.flutter.embedding.engine.FlutterJNI))nMissing class com.google.android.play.core.splitinstall.SplitInstallRequest$Builder (referenced from: void io.flutter.embedding.engine.deferredcomponents.PlayStoreDeferredComponentManager.installDeferredComponent(int, java.lang.String))nMissing class com.google.android.play.core.splitinstall.SplitInstallRequest (referenced from: void io.flutter.embedding.engine.deferredcomponents.PlayStoreDeferredComponentManager.installDeferredComponent(int, java.lang.String))nMissing class com.google.android.play.core.splitinstall.SplitInstallSessionState (referenced from: void io.flutter.embedding.engine.deferredcomponents.PlayStoreDeferredComponentManager$FeatureInstallStateUpdatedListener.onStateUpdate(com.google.android.play.core.splitinstall.SplitInstallSessionState) and 1 other context)nMissing class com.google.android.play.core.splitinstall.SplitInstallStateUpdatedListener (referenced from: void io.flutter.embedding.engine.deferredcomponents.PlayStoreDeferredComponentManager.<init>(android.content.Context, io.flutter.embedding.engine.FlutterJNI) and 2 other contexts)nMissing class com.google.android.play.core.tasks.OnFailureListener (referenced from: void io.flutter.embedding.engine.deferredcomponents.PlayStoreDeferredComponentManager.installDeferredComponent(int, java.lang.String))nMissing class com.google.android.play.core.tasks.OnSuccessListener (referenced from: void io.flutter.embedding.engine.deferredcomponents.PlayStoreDeferredComponentManager.installDeferredComponent(int, java.lang.String))nMissing class com.google.android.play.core.tasks.Task (referenced from: void io.flutter.embedding.engine.deferredcomponents.PlayStoreDeferredComponentManager.installDeferredComponent(int, java.lang.String) and 1 other context)","sources":[{}],"tool":"R8"}
Missing classes detected while running R8. Please add the missing classes or apply additional keep rules that are generated in /home/csaba/repos/flutter/track_my_indoor_exercise/build/app/outputs/mapping/release/missing_rules.txt.

Missing class com.google.android.play.core.splitcompat.SplitCompatApplication (referenced from: void io.flutter.app.FlutterPlayStoreSplitApplication.<init>() and 5 other contexts)
Missing class com.google.android.play.core.splitinstall.SplitInstallException (referenced from: void io.flutter.embedding.engine.deferredcomponents.PlayStoreDeferredComponentManager.lambda$installDeferredComponent$1(int, java.lang.String, java.lang.Exception))
Missing class com.google.android.play.core.splitinstall.SplitInstallManager (referenced from: com.google.android.play.core.splitinstall.SplitInstallManager io.flutter.embedding.engine.deferredcomponents.PlayStoreDeferredComponentManager.splitInstallManager and 5 other contexts)
Missing class com.google.android.play.core.splitinstall.SplitInstallManagerFactory (referenced from: void io.flutter.embedding.engine.deferredcomponents.PlayStoreDeferredComponentManager.<init>(android.content.Context, io.flutter.embedding.engine.FlutterJNI))
Missing class com.google.android.play.core.splitinstall.SplitInstallRequest$Builder (referenced from: void io.flutter.embedding.engine.deferredcomponents.PlayStoreDeferredComponentManager.installDeferredComponent(int, java.lang.String))
Missing class com.google.android.play.core.splitinstall.SplitInstallRequest (referenced from: void io.flutter.embedding.engine.deferredcomponents.PlayStoreDeferredComponentManager.installDeferredComponent(int, java.lang.String))
Missing class com.google.android.play.core.splitinstall.SplitInstallSessionState (referenced from: void io.flutter.embedding.engine.deferredcomponents.PlayStoreDeferredComponentManager$FeatureInstallStateUpdatedListener.onStateUpdate(com.google.android.play.core.splitinstall.SplitInstallSessionState) and 1 other context)
Missing class com.google.android.play.core.splitinstall.SplitInstallStateUpdatedListener (referenced from: void io.flutter.embedding.engine.deferredcomponents.PlayStoreDeferredComponentManager.<init>(android.content.Context, io.flutter.embedding.engine.FlutterJNI) and 2 other contexts)
Missing class com.google.android.play.core.tasks.OnFailureListener (referenced from: void io.flutter.embedding.engine.deferredcomponents.PlayStoreDeferredComponentManager.installDeferredComponent(int, java.lang.String))
Missing class com.google.android.play.core.tasks.OnSuccessListener (referenced from: void io.flutter.embedding.engine.deferredcomponents.PlayStoreDeferredComponentManager.installDeferredComponent(int, java.lang.String))
Missing class com.google.android.play.core.tasks.Task (referenced from: void io.flutter.embedding.engine.deferredcomponents.PlayStoreDeferredComponentManager.installDeferredComponent(int, java.lang.String) and 1 other context)

The rules file at the time of the error: https://github.com/TrackMyIndoorWorkout/TrackMyIndoorWorkout/blob/11d7bc8a1a6407dfe257ccbe6a68ac531c36719e/android/app/proguard-rules.pro

2

Answers


  1. Chosen as BEST ANSWER

    This turns out to be really Flutter related. I haven't disclosed my whole proguard rules because I have rules for every Flutter plugin to avoid MissingPluginExceptions (about that see https://csaba.page/blog/the-dreaded-missing-plugin-exception.html and rules I use https://csaba.page/blog/flutter-android-crash-remedies.html). The full rules file is like this: https://github.com/TrackMyIndoorWorkout/TrackMyIndoorWorkout/blob/11d7bc8a1a6407dfe257ccbe6a68ac531c36719e/android/app/proguard-rules.pro

    I took a second look at the longer (detailed) task error. I noted the referenced from: sections, and referenced from io.flutter.app..., io.flutter.embedding.engine.... And noticed that I have some rules about those because at some point in the past I treated a Flutter issue https://github.com/flutter/flutter/issues/78625#issuecomment-804164524

    I commented out the -keep class io.flutter.app.** { *; } and the -keep class io.flutter.** { *; } rules and now the app release build is successful. That section of the rules is like this now:

    # https://github.com/flutter/flutter/issues/78625#issuecomment-804164524
    #-keep class io.flutter.app.** { *; }
    -keep class io.flutter.plugin.** { *; }
    -keep class io.flutter.util.** { *; }
    -keep class io.flutter.view.** { *; }
    #-keep class io.flutter.** { *; }
    -keep class io.flutter.plugins.** { *; }
    

    With this I don't need to add any dontwarn or keep rules about the cited com.google.android.play.core... classes. I'll still need to test that build if it functions as expected.


  2. Add the following line to the release section of your app’s build.gradle:

    proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    

    This configures the proguard rules files for your Android app, and I have no idea why it’s not included by default.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search