141

Problem :

Error:Could not find com.android.support.constraint:constraint-layout:1.0.0-alpha2.
Required by:
myapp:app:unspecified

Background : Android Studio 2.2 P 1

2
  • I was working with AS 2.2 P 3 and it was fine
    – Humain
    Commented Jun 23, 2016 at 12:54
  • 1
    I just updated to AS2.2-alpha7... and it started error-ing out on me too. Commented Aug 2, 2016 at 11:44

23 Answers 23

331

Support libraries for ConstraintLayout could not be installed/updated.

Just open Preferences > Appearance & Behavior > System Settings > Android and move to SDK Tools tab. Check the following fields and install.

Preferences

7
  • 12
    For those who have these libraries installed but gradle is still complaining, check jmartinalonso's answer below. It is extending this answer.
    – Antimonit
    Commented Feb 11, 2017 at 2:26
  • 16
    Note: Preferences is actually File > Settings on Windows.
    – Sébastien
    Commented Feb 20, 2017 at 16:05
  • 7
    In my case I couldn't find AndroidSDK as mentioned here .So I executed ./sdkmanager "extras;m2repository;com;android;support;constraint;constraint-layout;1.0.0-beta4" from android-tools/bin. Commented Mar 3, 2017 at 12:42
  • Great helped me, but we need to sync and update both [ gradle and sdk tools versions] Commented Mar 27, 2017 at 11:13
  • 1
    As of Android Studio 2.3.3 on Windows, the mouse clicks required are File-->Settings-->Appearance & Behavior-->System Settings-->Android SDK-->SDK Tools tab. Then check "ConstraintLayout for Android" and "Solver for ConstraintLayout." Finally, Build-->Rebuild Project
    – pjd
    Commented Jul 11, 2017 at 2:57
132

In my case, that support libraries for ConstraintLayout were installed, but I was adding the incorrect version of ConstraintLayout Library in my build.gradle file. In order to see what version have you installed, go to Preferences > Appearance & Behavior > System Settings > Android SDK. Now, click on SDK Tools tab in right pane. Check Show Package Details and take note of the version.

enter image description here

Finally you can add the correct version in the build.gradle file

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha9'
    testCompile 'junit:junit:4.12'
}
15

The fix is to update the android gradle plugin in your build.gradle.

This should work: classpath 'com.android.tools.build:gradle:2.2.0-alpha2'

Or you can use the latest: classpath 'com.android.tools.build:gradle:2.2.0-alpha3'

1
12

My problem was, that the SDK Tools updated it to the latest version, in my case it was 1.0.0-alpha9, but in my gradle dependency was set to

compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha8' So, you can change your gradle build file to

compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha9' Or you check "Show package details" in the SDK Tools Editor and install your needed version. See screenshow below. Image of SDK Tools

enter image description here

11
  1. Ensure you have the maven.google.com repository declared in your module-level build.gradle file

    repositories { maven { url 'https://maven.google.com' } }

2.Add the library as a dependency in the same build.gradle file:

dependencies {
      compile 'com.android.support.constraint:constraint-layout:1.0.2'
}
8

I updated my android gradle plugin to 2.2.0-alpha4 and constraint layout dependency to 1.0.0-alpha3 and it seems to be working now

1
  • Thanks this worked for me. Gradle updated itself after popup but not the constraint dependency
    – Chris
    Commented Jun 30, 2016 at 17:40
6

First I tried everything that I have read on stackoverflow...from updating gradle to XY version, to updating ConstraintLayout to XY version...I even update my SDK tools and Android Studio to the latest version...but nothing was working.

The only solution that worked for me was that I delete ConstraintLayout library from gradle and SDK, then I opened random xml layout and in Design view under Palette section search for ConstraintLayout. If you have successfully deleted library from your project then you will be able to install the library from there if you double clicked on ConstraintLayout element.

That has create next line in my app build.gradle:

'com.android.support.constraint:constraint-layout:1.0.0-beta1'

In my project build.gradle I have this:

classpath 'com.android.tools.build:gradle:2.2.2'

Android studio version 2.2.2

1
  • Yes I agreed with your answer Commented Oct 6, 2017 at 9:11
5

Alpha version is no longer available !

implementation 'com.android.support.constraint:constraint-layout:1.1.3'
2
  • Use latest version of contraint-layout Commented Oct 4, 2019 at 9:17
  • 1
    Where would one add this line of code? I have latest android version 3.6 and I do not have a Support Repository option in SDK Tools Commented Mar 23, 2020 at 12:34
3

Just to make sure that in studio version 2.3 you won't see a dropdown near constraint-layout in sdk tools, it will by default install the latest version

To get the desired version check the box saying show package details and boom you can now choose the desired version you want to install

1
  • I was stuck on this until I saw your post I needed a specific older version of these. Great tip!
    – Baxter
    Commented May 22, 2017 at 19:17
1

gradle com.android.tools.build:gradle:2.2.0-alpha6

constraint layout dependency com.android.support.constraint:constraint-layout:1.0.0-alpha4

works for me

1

For me it was a completely different issue. When I installed constraint dependancy in SDK tools, the tools somehow wrote them into the wrong directory. That is

/home/${USER}/Android/Sdk/extras/+m2repository+/com/.../constraint

instead of

/home/${USER}/Android/Sdk/extras/+android+/+m2repository+/com/.../constraint

Remedy:

Just copy the 1.0.0-alpha* directories into the latter path

1

While updating SDK tools, a dilog box presented with Constraint layout version that is going to get installed. Note that and update your dependency based on that. In my case it was installing beta3.

I changed my dependency like below. After that it worked.

compile 'com.android.support.constraint:constraint-layout:1.0.0-beta3'

1

In my case, I had to remove the previous versions first and download the latest one instead. v1.0 stable was released on Feb 23rd. enter image description here

1

In my case, I had a multi-module project called "app" and "sdk". The "sdk" module is the one where I had added the constraint layout library. I got the error when I tried to incorporate "sdk" into a new multi-module project called "app2". The solution was to ensure I had added the Google Maven Repository to the project-level build.gradle file for "app2". The Google Maven Repository can be added by putting "google()" under allprojects.repositories in the project-level build.gradle file:

allprojects {
    repositories {
        jcenter()
        google()
    }
}
1

In my case, I was using AS 2.3 and I wanted to use the currently latest ConstraintLayout 1.1.3, but the latest version in my Preferences > Appearance & Behavior > System Settings > Android was 1.0.2.

To use ConstraintLayout 1.1.3, I updated my AS from 2.3 to currently latest 3.2.1, com.android.tools.build:gradle from 2.2.2 to 3.2.1, gradle from 3.3 to 4.6 and buildToolsVersion from 25.0.0 to 28.0.3.

I also added maven { url 'https://maven.google.com' } to the Maven repositories in the project-level build.gradle file and that solved my problem.

1

Just as a heads up to those still searching for this.

ConstraintLayout 1.0.1 and lower have been deprecated by maven.

For a list of available constraint layouts that can be downloaded, see below:

https://maven.google.com/web/index.html?q=Constrain#com.android.support.constraint:constraint-layout

The easiest solution at the moment, is to change

implementation 'com.android.support.constraint:constraint-layout:1.0.0-beta1'

to

implementation 'com.android.support.constraint:constraint-layout:1.0.2'

0

I used com.android.support.constraint:constraint-layout:1.0.0-alpha2 with classpath 'com.android.tools.build:gradle:2.1.0', it worked like charm.

0

Not sure if I'm too late, but in case someone has still the error after an update of ConstraintLayout and Solver over the SDK Tools, maybe this solution could help: Error:(30, 13) Failed to resolve: com.android.support.constraint:constraint-layout:1.0.0-alpha4

0

Its available in androidx as following package

implementation "androidx.constraintlayout:constraintlayout:2.0.0-alpha1"
0

Update your constraint layout dependency to the relevant version from '1.0.0-alpha2'. In my case, I changed to the following. compile 'com.android.support.constraint:constraint-layout:2.0.0-alpha5'

0

I added the following script in build.gradle(app) under android & I was able to compile.

compileOptions {
    sourceCompatibility 1.8
    targetCompatibility 1.8
}
-2

Similar issue solved by Reinstalling Android Studio.

1
  • I guess a simpler solution is expected.
    – Louis
    Commented Oct 27, 2019 at 14:46
-4

enter image description here

i'm try constraint layout dependency update available 1,and plugin gradle alpha-6,it worked

Not the answer you're looking for? Browse other questions tagged or ask your own question.