0

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)

screenshot

Is there something that I missing?

Prags
  • 2,457
  • 2
  • 21
  • 38
Ariel Carbonaro
  • 1,529
  • 1
  • 13
  • 25
  • Can you file a bug to Google, then link to it back in here? It would be helpful for all, thanks! https://issuetracker.google.com/issues/new?component=316045&template=1018787 , And they might need a sample project to take a closer look. – ManmeetP Oct 27 '17 at 05:48
  • 1
    the italics means that it's just a reference, not the actual class – fede1608 Dec 04 '17 at 18:28

1 Answers1

1

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.

Kevin Crain
  • 1,905
  • 1
  • 19
  • 28