当minifyEnabled启用时,使用Material Components 1.1.0-alpha06启动时应用崩溃

时间:2019-06-03 06:16:44

标签: android mdc-components

自从我添加了最新材料库的依赖关系以来,我的应用程序在启动时崩溃:

implementation 'com.google.android.material:material:1.1.0-alpha06'

这仅在我使用minifyEnabled true测试时发生。没有它就可以正常工作。

崩溃日志在下面-它似乎从未接触过我的代码,显然甚至在崩溃之前就崩溃了。

我猜材料库使用反射,并且我需要在Proguard规则文件中添加更多规则。我可以从mdc-android repository中找到这些,但它们尚未解决问题:

# MaterialComponentsViewInflater inflates Material Components rather than their AppCompat counterparts.
-keep class com.google.android.material.theme.MaterialComponentsViewInflater { *; }


# CoordinatorLayout resolves the behaviors of its child components with reflection.
-keep public class * extends androidx.coordinatorlayout.widget.CoordinatorLayout$Behavior {
    public <init>(android.content.Context, android.util.AttributeSet);
    public <init>();
}

# Make sure we keep annotations for CoordinatorLayout's DefaultBehavior
-keepattributes RuntimeVisible*Annotation*

非常感谢您提供解决此问题的帮助!


崩溃日志:

java.lang.LinkageError: Method void g.a.a.g.e.a() overrides final method in class Lb/n/I; (declaration of 'g.a.a.g.e' appears in /data/app/net.c306.ttsuper-Xpl60mXuZR_TLN-idGkg1Q==/base.apk)
        at java.lang.Class.newInstance(Native Method)
        at android.app.AppComponentFactory.instantiateActivity(AppComponentFactory.java:69)
        at androidx.core.app.CoreComponentFactory.instantiateActivity(SourceFile:41)
        at android.app.Instrumentation.newActivity(Instrumentation.java:1215)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2831)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6669)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

0 个答案:

没有答案