After migrating to Androidx packages using Android Studio menu option Refactor -> Refactor to Androidx...
I'm getting the following error:
Error inflating class androidx.constraintlayout.widget.ConstraintLayout
ConstraintLayout. A ConstraintLayout is a ViewGroup which allows you to position and size widgets in a flexible way. ConstraintLayout.LayoutParams. This class contains the different attributes specifying how a view want to be laid out inside a ConstraintLayout .
androidx.constraintlayout.widget.Barrier. Added in 1.1. A Barrier references multiple widgets as input, and creates a virtual guideline based on the most extreme widget on the specified side. For example, a left barrier will align to the left of all the referenced views.
These attributes are not applied at runtime, so if you push your layout on a device, the widgets may appear in a different location than shown in the editor. To fix this, make sure a widget has both horizontal and vertical constraints by dragging from the edge connections.
Make sure constraint layout is updated to latest version:
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
And replace your xml tag names
<androidx.constraintlayout.ConstraintLayout>
with
<androidx.constraintlayout.widget.ConstraintLayout>
in every place where it appears using this shortcut:
Windows: CTRL + SHIFT + R
Mac: COMMAND + SHIFT + R
In AndroidStudio 3.3 RC2 I got it resolved by upgrading -
implementation 'androidx.constraintlayout:constraintlayout:1.1.2'
to
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
in build.gradle (Module: app)
Note: This solution is also valid for the release version 3.3 (as per below comment by FireZenk), 3.5.2 (as per below comment by user2350644)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With