当我构建一个APK时,它出来是30 MB。我最近从7. 4升级到AGP 8. 1,不确定这是否搞砸了什么。Task :app:minifyReleaseWithR8 FAILED
失败。短信内容为:
运行R8时检测到缺少类。请添加缺少的类或应用在/home/csaba/repos/flutter/track_my_indoor_exercise/build/app/outputs/mapping/release/missing_rules.txt中生成的其他保持规则。
引用的文件包含:
# 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
字符串
我试着加上
-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.** { *; }
型
在我的防护系统里,甚至还试图
-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
型
但同样的班级仍然报告失踪。好像ProGuard文件被忽略了
较长任务错误:
> 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)
1条答案
按热度按时间2ul0zpep1#
事实证明,这真的与Flutter有关。我没有公开我的全部proguard规则,因为我为每个Flutter插件都制定了避免
MissingPluginException
的规则(关于这一点,请参阅https://csaba.page/blog/the-dreaded-missing-plugin-exception.html和我使用https://csaba.page/blog/flutter-android-crash-remedies.html的规则)。完整的rules文件如下所示:https://github.com/TrackMyIndoorWorkout/TrackMyIndoorWorkout/blob/11d7bc8a1a6407dfe257ccbe6a68ac531c36719e/android/app/proguard-rules.pro的我再次查看了较长的(详细的)任务错误。我注意到了
referenced from:
部分,并引用了io.flutter.app...
,io.flutter.embedding.engine...
。注意到我有一些关于这些的规则,因为在过去的某个时候,我处理了一个Flutter问题https://github.com/flutter/flutter/issues/78625#issuecomment-804164524我注解掉了
-keep class io.flutter.app.** { *; }
和-keep class io.flutter.** { *; }
规则,现在应用程序发布构建成功了。现在的规则是这样的:字符串
这样我就不需要添加任何关于引用的
com.google.android.play.core...
类的dontwarn
或keep
规则。我仍然需要测试该构建是否按预期运行。