140

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

Cool
  • 10,038
  • 13
  • 56
  • 77

22 Answers22

328

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

gokhanakkurt
  • 4,845
  • 4
  • 27
  • 39
  • 12
    For those who have these libraries installed but gradle is still complaining, check `jmartinalonso`'s answer below. It is extending this answer. – Antimonit Feb 11 '17 at 02:26
  • 16
    Note: `Preferences` is actually `File` > `Settings` on Windows. – Sébastien Feb 20 '17 at 16:05
  • 7
    In my case I couldn't find AndroidSDK as mentioned [here](http://stackoverflow.com/questions/42252340/cant-find-android-sdk-on-android-studio-preferences) .So I executed `./sdkmanager "extras;m2repository;com;android;support;constraint;constraint-layout;1.0.0-beta4"` from android-tools/bin. – Hareendra Chamara Philips Mar 03 '17 at 12:42
  • Great helped me, but we need to sync and update both [ gradle and sdk tools versions] – Syed Raheem Uddin Mar 27 '17 at 11:13
  • I'm running on Ubuntu, and my ~/Android/Sdk/extras/m2repository was owned by root:root. I chowned it to my user, and I could then update the library. – Steve Gelman Jun 04 '17 at 20:56
  • 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 Jul 11 '17 at 02:57
  • My current version is 3.0 i have tried your ways but its not solved :( – Sagar Roy Mar 28 '18 at 17:48
131

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'
}
RBT
  • 18,275
  • 13
  • 127
  • 181
jmartinalonso
  • 2,064
  • 1
  • 14
  • 19
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'

Siddharth Lele
  • 26,905
  • 15
  • 91
  • 144
Johnny
  • 2,450
  • 5
  • 23
  • 32
  • 2
    Be careful with using 2.2.0-alpha3 there is a bug with Toolbar on Android 4.x http://stackoverflow.com/questions/37812115/android-click-highlight-issue-after-updating-to-android-studio-2-2-preview-3 – Than Jun 24 '16 at 10:11
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

Anshul Agarwal
  • 1,365
  • 11
  • 16
10
  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'
}
savepopulation
  • 10,674
  • 4
  • 47
  • 68
Rohan
  • 750
  • 10
  • 20
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

sven
  • 249
  • 3
  • 10
  • Thanks this worked for me. Gradle updated itself after popup but not the constraint dependency – Chris Jun 30 '16 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

BVantur
  • 651
  • 8
  • 8
5

Alpha version is no longer available !

implementation 'com.android.support.constraint:constraint-layout:1.1.3'
Tiago Simões
  • 51
  • 1
  • 2
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

madhur
  • 903
  • 1
  • 11
  • 20
  • I was stuck on this until I saw your post I needed a specific older version of these. Great tip! – Baxter May 22 '17 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

Lukas Lechner
  • 6,533
  • 5
  • 35
  • 51
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

Community
  • 1
  • 1
peterchaula
  • 2,696
  • 2
  • 20
  • 28
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'

SoftwareGuy
  • 337
  • 2
  • 11
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

mhdtouban
  • 810
  • 1
  • 10
  • 19
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.

Allan
  • 141
  • 1
  • 7
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.

androidStud
  • 414
  • 3
  • 9
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

Community
  • 1
  • 1
Camino2007
  • 657
  • 7
  • 16
0

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()
    }
}
Michael Osofsky
  • 7,571
  • 7
  • 42
  • 87
0

Its available in androidx as following package

implementation "androidx.constraintlayout:constraintlayout:2.0.0-alpha1"
Uzair
  • 1,413
  • 13
  • 16
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

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'

Russy
  • 26
  • 6
-1

Similar issue solved by Reinstalling Android Studio.

spacedev
  • 624
  • 7
  • 12
-4

enter image description here

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

Shabbir Dhangot
  • 8,089
  • 9
  • 55
  • 75
qydq
  • 7
  • 2