Search code examples
androidxmllayoutdependenciesandroidx

AndroidX dependencies and XML causing crash


I recently updated to Android 3.3, Now a lot of dependencies are changed to AndroidX. Which is causing the app to crash, along with dependency changes need to be done in XML as well. I faced a similar issue with CoordinatorLayout. I searched stackoverflow there aren't a lot of Questions on this topic, since AndroidX is relatively new. So i felt the need to raise a question in this regard.

Where can i get xml for FloatingActionButton similarly for all the XML is there a website where we can get the XML for androidX dependencies.

XML

 <android.support.design.widget.FloatingActionButton

Crash Logcat

android.view.InflateException: Binary XML file line #15: Binary XML file line #15: Error inflating class android.support.design.widget.FloatingActionButton Caused by: android.view.InflateException: Binary XML file line #15: Error inflating class android.support.design.widget.FloatingActionButton Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.design.widget.FloatingActionButton" on path: DexPathList[[zip file "/data/app/com.kc.unsplashdemo-kTZQS-p2845Xly7PcTuAmg==/base.apk", zip file "/data/app/com.kc.unsplashdemo-kTZQS-p2845Xly7PcTuAmg==/split_lib_dependencies_apk.apk", zip file

dependencies

dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
        implementation project(':androidunsplash')
        implementation 'com.squareup.picasso:picasso:2.71828'
        implementation("com.squareup.okhttp3:okhttp:3.12.0")
        implementation 'androidx.recyclerview:recyclerview:1.0.0'
        implementation 'com.google.code.gson:gson:2.8.5'
    
        implementation 'com.google.android.material:material:1.0.0'
        implementation 'androidx.appcompat:appcompat:1.0.2'
        implementation 'androidx.constraintlayout:constraintlayout:1.1.1'
    }

Solution

  • You can find the mapping for the old android dependencies against the new ones who use androidx here

    There you'll find this for the dependency you're looking for:

    com.google.android.material.floatingactionbutton.FloatingActionButton
    

    When replacing something on a layout I'd suggest using ctrl + r to update it in the whole project and save you time, as there's indeed quite a bit of manual work to do when migrating to androidx.