添加proguard后,Android DataBinding不会变形

时间:2018-04-12 13:07:00

标签: java android data-binding proguard android-proguard

我面临着android数据绑定和proguard规则的问题,

从gradle文件启用android数据绑定

 dataBinding {
            enabled = true
        }

在gradle文件中添加proguard之前,数据绑定工作正常 当 minifyEnabled 设置false app正常工作时

debug {
            debuggable true
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }

如果我将 minifyEnabled 更改为true,则应用程序会在绑定视图中崩溃。

debug {
            debuggable true
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }

并显示错误

W/ActivityManager: Unbind failed: could not find connection for android.os.BinderProxy@426364e8

04-12 18:30:57.666 15455-15455/com.theskillsrainbow D/AndroidRuntime: Shutting down VM
04-12 18:30:57.666 15455-15455/com.theskillsrainbow W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x4170bba8)
04-12 18:30:57.666 15455-15455/com.theskillsrainbow W/System.err: java.lang.NullPointerException
04-12 18:30:57.666 15455-15455/com.theskillsrainbow W/System.err:     at com.theskillsrainbow.f.s$1.a(Unknown Source)
04-12 18:30:57.666 15455-15455/com.theskillsrainbow W/System.err:     at d.g$a$1$1.run(Unknown Source)
04-12 18:30:57.666 15455-15455/com.theskillsrainbow W/System.err:     at android.os.Handler.handleCallback(Handler.java:733)
04-12 18:30:57.667 15455-15455/com.theskillsrainbow W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:95)
04-12 18:30:57.667 15455-15455/com.theskillsrainbow W/System.err:     at android.os.Looper.loop(Looper.java:136)
04-12 18:30:57.667 15455-15455/com.theskillsrainbow W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:5028)
04-12 18:30:57.667 15455-15455/com.theskillsrainbow W/System.err:     at java.lang.reflect.Method.invokeNative(Native Method)
04-12 18:30:57.667 15455-15455/com.theskillsrainbow W/System.err:     at java.lang.reflect.Method.invoke(Method.java:515)
04-12 18:30:57.667 15455-15455/com.theskillsrainbow W/System.err:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:788)
04-12 18:30:57.667 15455-15455/com.theskillsrainbow W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:604)
04-12 18:30:57.667 15455-15455/com.theskillsrainbow W/System.err:     at dalvik.system.NativeStart.main(Native Method)

我使用的数据绑定的Proguard规则

#databinding
-dontwarn android.databinding.**
-keep class android.databinding.** { *; }
-keep class android.databinding.annotationprocessor.** { *; }

0 个答案:

没有答案