问题描述
我的代码中没有几个自定义视图,并且正在布局文件中使用它们。对于此处的ExpandableAppBarBehavior,请参见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"
>
到目前为止,它仍然可以正常工作,但是当我使用新的applicationId com.example.flavor1创建新的样式时,它开始在运行时出现错误。
要包含我放置的默认软件包中的资源
javaCompileOptions {
annotationProcessorOptions {
arguments = ["resourcePackageName": "com.example"]
}
}
在build.gradle
但是在运行时会出现错误:
java.lang.RuntimeException: Could not inflate BehavIoUr subclass com.example.flavor1.views.ExpandableAppBarBehavior
您能告诉我我在做什么错吗?
解决方法
只是为了帮助某人,如果有人遇到相同的问题,我会通过提供Custom类的完整路径来解决它
<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"
>
请记住,我们必须提供默认的applicationId。