Getting ConstraintLayout

Since ConstraintLayout comes from a library, we need to ensure that we have this library in our module. If you create the project from the Android Studio new-project wizard, it is very likely that you already have the library in your dependencies.

What you are looking for is androidx.constraintlayout:constraintlayout for some version:

dependencies {
  implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
  implementation 'androidx.appcompat:appcompat:1.3.1'
  implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
  implementation "androidx.activity:activity:1.3.1"
}

You may find that you have a different artifact, com.android.support.constraint:constraint-layout. This too provides ConstraintLayout, but it is the older artifact, from the Android Support Library. If you have other artifacts in your dependencies that are androidx-based, you will want to use the androidx edition of the constraintlayout artifact.


Prev Table of Contents Next

This book is licensed under the Creative Commons Attribution-ShareAlike 4.0 International license.