Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not inflate and Didn't find class Behavior of android support design BottomSheetBehavior

I am trying to implement bottom modal sheet to my main project. I successfully did it in a single demo project. But when I am applying same structure to my main project then the app crashes with the following error:

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........]]

I tried the previously stated app:layout_behavior="@string/bottom_sheet_behavior" in my xml but it didn't work.

In the demo project the bottom sheet works properly in nested parent view.

My main project dependencies are - (added to 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"
like image 678
Partho Bhowmick Avatar asked Jun 25 '19 11:06

Partho Bhowmick


1 Answers

You are using the new Material Components for Android as a dependency and not the "old" Android Design Support Library. However you are referencing the string android.support.design.widget.BottomSheetBehavior from the old library which isn't there anymore. So in order to make it work simply change the app:layout_behavior from

android.support.design.widget.BottomSheetBehavior

to

com.google.android.material.bottomsheet.BottomSheetBehavior
like image 149
reVerse Avatar answered Sep 21 '22 06:09

reVerse