Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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'
    }
like image 469
Amir Dora. Avatar asked Feb 17 '19 09:02

Amir Dora.


2 Answers

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.

like image 200
Francislainy Campos Avatar answered Oct 03 '22 04:10

Francislainy Campos


Adding a dependency for androidX is not enough. To migrate your components to the androidX one, you have to change them manually. While searching for all the new packages may be time consuming, I can suggest you to try deleting old name in your xml and then start typing a new one. If androidX dependencies are really added to your project, after you started typing Android Studio will suggest you a new package name. enter image description here enter image description here enter image description here

Furthermore, you can look for additional information here

like image 33
Stanislav Shamilov Avatar answered Oct 03 '22 04:10

Stanislav Shamilov