gpt4 book ai didi

android - Could not inflate and Didn't find class Behavior of android支持设计BottomSheetBehavior

转载 作者:行者123 更新时间:2023-11-29 15:33:57 46 4
gpt4 key购买 nike

我正在尝试为我的主要项目实现底部模式表。我在一个演示项目中成功地做到了。但是当我将相同的结构应用于我的主项目时,应用程序崩溃并出现以下错误:

android.view.InflateException: Binary XML file line #40: Could not inflate Behavior subclass android.support.design.widget.BottomSheetBehavior Caused by: java.lang.RuntimeException: Could not inflate Behavior subclass android.support.design.widget.BottomSheetBehavior

AndroidRuntime: Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.design.widget.BottomSheetBehavior" on path: DexPathList[[zip file "/data/app/com.example........]]

我在我的 xml 中尝试了前面所述的 app:layout_behavior="@string/bottom_sheet_behavior" 但它没有用。

在演示项目中, Bottom Sheet 在嵌套父 View 中正常工作。

我主要的项目依赖是-(添加到app build.gradle)

    def lifecycle_version = "2.1.0-alpha02"
def room_version = "2.1.0-alpha04"
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'com.github.bumptech.glide:glide:4.9.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'me.relex:circleindicator:2.1.0'
implementation 'com.squareup.retrofit2:retrofit:2.5.0'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.squareup.retrofit2:converter-gson:2.5.0'
implementation 'com.github.chrisbanes:PhotoView:2.3.0'

// ViewModel and LiveData
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
annotationProcessor "androidx.lifecycle:lifecycle-compiler:$lifecycle_version"
implementation "androidx.room:room-runtime:$room_version"
annotationProcessor "androidx.room:room-compiler:$room_version"

最佳答案

您正在使用新的 Material Components for Android作为依赖而不是“旧”Android Design Support Library .但是,您正在引用旧库中的字符串 android.support.design.widget.BottomSheetBehavior ,该库不再存在。因此,为了使其正常工作,只需将 app:layout_behavior

更改为
android.support.design.widget.BottomSheetBehavior

com.google.android.material.bottomsheet.BottomSheetBehavior

关于android - Could not inflate and Didn't find class Behavior of android支持设计BottomSheetBehavior,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56753200/

46 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com