Is there an minimum android version to use android-ConstraintLayout?

android constraint layout responsive design
androidx constraintlayout
constraintlayout version
android constraintlayout guideline
android constraintlayout barrier
android-constraintlayout programmatically
constraint layout in android tutorials point
when to use constraint layout

I have a problem with android ConstraintLayout feature... In my app I use a ConstraintLayout, everything works fine when I install my app on a 9+ android version, but when I install the app on a lower android version the app is crashing. In my android project I have: minSdkVersion 21 targetSdkVersion 26 compileSdkVersion 28

Anyone have any idea what might causing it? Or a way to fix it?

Edit: Thanks to @Nikos Hidalgo! I didn't understand the error message correctly. it was my gradient background that broke everything..

The error I get is as follows:

11-12 15:44:32.580 11651-11651/? E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.repondeurtexto, PID: 11651
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.repondeurtexto/com.example.repondeurtexto.FirstActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class androidx.constraintlayout.widget.ConstraintLayout
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3150)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3260)
        at android.app.ActivityThread.access$1000(ActivityThread.java:218)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1734)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:145)
        at android.app.ActivityThread.main(ActivityThread.java:6934)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:372)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
     Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class androidx.constraintlayout.widget.ConstraintLayout
        at android.view.LayoutInflater.createView(LayoutInflater.java:640)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:750)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:483)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:415)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:366)
        at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
        at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
        at com.example.repondeurtexto.FirstActivity.onCreate(FirstActivity.java:15)
        at android.app.Activity.performCreate(Activity.java:6609)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1134)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3103)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3260) 
        at android.app.ActivityThread.access$1000(ActivityThread.java:218) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1734) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:145) 
        at android.app.ActivityThread.main(ActivityThread.java:6934) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at java.lang.reflect.Method.invoke(Method.java:372) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199) 
     Caused by: java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Constructor.newInstance(Native Method)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
        at android.view.LayoutInflater.createView(LayoutInflater.java:614)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:750) 
        at android.view.LayoutInflater.inflate(LayoutInflater.java:483) 
        at android.view.LayoutInflater.inflate(LayoutInflater.java:415) 
        at android.view.LayoutInflater.inflate(LayoutInflater.java:366) 
        at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469) 
        at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
        at com.example.repondeurtexto.FirstActivity.onCreate(FirstActivity.java:15) 
        at android.app.Activity.performCreate(Activity.java:6609) 
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1134) 
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3103) 
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3260) 
        at android.app.ActivityThread.access$1000(ActivityThread.java:218) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1734) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:145) 
        at android.app.ActivityThread.main(ActivityThread.java:6934) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at java.lang.reflect.Method.invoke(Method.java:372) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199) 
     Caused by: android.content.res.Resources$NotFoundException: Resource "com.example.repondeurtexto:drawable/gradient" (7f07006c)  is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f07006c a=-1 r=0x7f07006c}
        at android.content.res.Resources.loadDrawableForCookie(Resources.java:4017)
        at android.content.res.Resources.loadDrawable(Resources.java:3929)
        at android.content.res.Resources.loadDrawable(Resources.java:3779)
        at android.content.res.TypedArray.getDrawable(TypedArray.java:776)
        at android.view.View.<init>(View.java:4001)
        at android.view.ViewGroup.<init>(ViewGroup.java:513)
        at android.view.ViewGroup.<init>(ViewGroup.java:509)
        at android.view.ViewGroup.<init>(ViewGroup.java:505)
        at androidx.constraintlayout.widget.ConstraintLayout.<init>(ConstraintLayout.java:575)
        at java.lang.reflect.Constructor.newInstance(Native Method) 
        at java.lang.reflect.Constructor.newInstance(Constructor.java:288) 
        at android.view.LayoutInflater.createView(LayoutInflater.java:614) 
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:750) 
        at android.view.LayoutInflater.inflate(LayoutInflater.java:483) 
        at android.view.LayoutInflater.inflate(LayoutInflater.java:415) 
        at android.view.LayoutInflater.inflate(LayoutInflater.java:366) 
        at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469) 
        at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
        at com.example.repondeurtexto.FirstActivity.onCreate(FirstActivity.java:15) 
        at android.app.Activity.performCreate(Activity.java:6609) 
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1134) 
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3103) 
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3260) 
        at android.app.ActivityThread.access$1000(ActivityThread.java:218) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1734) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:145) 
        at android.app.ActivityThread.main(ActivityThread.java:6934) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at java.lang.reflect.Method.invoke(Method.java:372) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)

In my build.gradle I set this:

implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

As the documentation states, ConstraintLayout for now is only available as a support library that you can use on Android systems starting with API level 9 (Gingerbread).

Build a Responsive UI with ConstraintLayout, ConstraintLayout allows you to create large and complex layouts with a flat view so each Duration: 4:00 Posted: Dec 20, 2016 I have a ConstraintLayout inside a NestedScrollView.The ConstraintLayout contains a bunch of views but the last View can have a dynamic height to fill up the bottom space iff there is any but it also needs to be a minimum height if there is not enough space.

ConstraintLayout is available in an API library that's compatible with Android 2.3 (API level 9) and higher. This page provides a guide to building a layout with ConstraintLayout in Android Studio 2.3 or higher.

Build responsive UI with ContraintLayout

Ensure you have the required modules in your gradle.Also see this link to solve NullPointExceptions

Check if you have ids that are conflicting with the new design library.

Check your XML file name,make sure your XML file name is included in your MainActivity layout:

setContentView(R.layout.xmlfilename_main); 

ConstraintLayout, As such, we are planning on enriching its API and capabilities over time. There are currently various types of constraints that you can use: You can define minimum and maximum sizes for the ConstraintLayout itself:. To convert an existing layout to a constraint layout, follow these steps: Open your layout in Android Studio and click the Design tab at the bottom of the editor window.; In the Component Tree window, right-click the layout and click Convert layout to ConstraintLayout.

Your targetSdkVersion and compileSdkVersion should be same.

targetSdkVersion 28
compileSdkVersion 28

ConstraintLayout 1.0 is now available, We recommend updating to this version, particularly if used in production. Note: with Android Studio 2.3 reaching release candidate status, we also encourage The ConstraintLayout library allows you to create complex layouts easily, avoiding deep Flexible size control (min/max/wrap/constrained). If you don't need the new features in Android 9 yet, and only want to compile against that version of the platform, you can use Android Studio 3.1. Android Studio 3.2 provides complete support for Android 9 features. To get set up with either version of Android Studio, follow the steps documented in Set up the Preview SDK. Test your Android 9 app

Use ConstraintLayout to design your Android views, Before you begin. In this codelab, you'll learn how to use the Android Studio Layout Editor with ConstraintLayout—a new, flexible, and efficient layout available� In old versions of Android Studio you would not see the newly created guideline until you clicked on the blueprint view. If you are using an old version of Android Studio and don’t see the guideline you just created, just click anywhere inside blueprint view and it’ll appear. Types of Guideline. There are three distinct types of guideline.

Android ConstraintLayout Example Tutorial, To use android ConstraintLayout, make sure you're using the latest Android Studio version. Ideally, Android Studio 2.2 and above. We need to download the � Constraint Layout Tutorial With Example In Android Studio [Step by Step] Constraint Layout is a ViewGroup (i.e. a view that holds other views) which allows you to create large and complex layouts with a flat view hierarchy, and also allows you to position and size widgets in a very flexible way.

ConstraintLayout Tutorial for Android: Getting Started , Android provides various types of layouts which use different methods ConstraintLayout , which is now the default layout in Android Studio, gives you Open Android Studio version 3.2.1 or greater and create a new Android because Android Studio now has the minimal amount of information needed� There has been lots of new features in version 1.1, but we will talk about the percentage feature here. In Constraint Layout 1.0 making a view take up a percentage of the screen required making two guidelines.

Comments
  • this is the line in your logcat you should be paying attention to: Caused by: android.content.res.Resources$NotFoundException: Resource "com.example.repondeurtexto:drawable/gradient" (7f07006c) is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f07006c a=-1 r=0x7f07006c} API21 can support constraint layout just fine.
  • Could you post your xml please?
  • have a look at this stackoverflow.com/questions/29095063/…
  • not sure if that's where the issue lies. Target SDK doesn't have to be the same as Compile SDK.