I have few custom views in my code and I am using them in layout files. For ex- ExpandableAppBarBehavior here in AppBArLayout

  <com.google.android.material.appbar.AppBarLayout
        android:id="@+id/app_bar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true"
        app:expanded="false"
        android:background="#1CF2F2"
        app:layout_behavior=".views.ExpandableAppBarBehavior"
        >

It was working fine till now, but when I created a new flavor with new applicationId com.example.flavor1 then it started giving error at runtime.

To include resources from default package I have put

javaCompileOptions {
            annotationProcessorOptions {
                arguments = ["resourcePackageName": "com.example"]
            }
        }

in build.gradle

But in runtime its giving an error:

java.lang.RuntimeException: Could not inflate Behaviour subclass com.example.flavor1.views.ExpandableAppBarBehavior

Could you please tell me what I am doing wrong here?

1

There are 1 answers

0
Anupriya On

Just to help someone, if someone got stuck with same issue, I resolve it by providing full path of Custom class

 <com.google.android.material.appbar.AppBarLayout
        android:id="@+id/app_bar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true"
        app:expanded="false"
        android:background="#1CF2F2"
        app:layout_behavior="com.example.views.ExpandableAppBarBehavior"
        >

Here to keep in mind, we have to provide default applicationId.