简体   繁体   中英

NoClassDefFoundError failed resolution of databinding class in base module

I've just restructured my project in order to support instant apps, splitting my project in 3 different modules. I've successfully deployed my Instant App, but after a couple of test I noticed a crash at one activity that uses data biding.

I'm aware that DataBinding is only supported in the base Feature, so I have the class that references it and the layout in the base module. Also I added the ProGuard's rule to keep the data binding class.

Here is the stack trace of the crash:

    FATAL EXCEPTION: main Process: 
        com.yopapp.yop, PID: 5516 java.lang.NoClassDefFoundError: Failed resolution of: 
Lcom/yopapp/yop/databinding/CardViewItemHeaderBinding;
    at com.yopapp.yop.a.j.a(DealDetailAdapter.java:258)
    at com.yopapp.yop.a.j.onCreateViewHolder(DealDetailAdapter.java:51)
    at android.support.v7.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:6493)
    at android.support.v7.widget.RecyclerView$Recycler.a(RecyclerView.java:5680)

Proguard rules:

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

-dontwarn com.yopapp.yop.databinding.**
-keep class com.yopapp.yop.databinding.** { *; }

Also if I analyze the APK, I can see the com.yopapp.yop.databinding package and the CardViewItemHeaderBinding class (but in italic font, I don't know why)

截图

Is there something that I missing?

I found if you use the same package name inside AndroidManifest.xml in your library as your app then java.lang.NoClassDefFoundError occurs for your databinding classes. Try using a different package name for your library modules.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM