Gradle Sync failed could not find constraint-layout:1.0.0-alpha2

150,895

Solution 1

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

Solution 2

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'
}

Solution 3

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'

Solution 4

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

Solution 5

  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'
}
Share:
150,895
TooCool
Author by

TooCool

Updated on September 22, 2021

Comments

  • TooCool
    TooCool almost 3 years

    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

  • Than
    Than about 8 years
    Be careful with using 2.2.0-alpha3 there is a bug with Toolbar on Android 4.x stackoverflow.com/questions/37812115/…
  • Chris
    Chris almost 8 years
    Thanks this worked for me. Gradle updated itself after popup but not the constraint dependency
  • Antimonit
    Antimonit over 7 years
    For those who have these libraries installed but gradle is still complaining, check jmartinalonso's answer below. It is extending this answer.
  • Sébastien
    Sébastien over 7 years
    Note: Preferences is actually File > Settings on Windows.
  • Hareendra Chamara Philips
    Hareendra Chamara Philips over 7 years
    In my case I couldn't find AndroidSDK as mentioned here .So I executed ./sdkmanager "extras;m2repository;com;android;support;constraint;constrai‌​nt-layout;1.0.0-beta‌​4" from android-tools/bin.
  • Syed Raheem Uddin
    Syed Raheem Uddin over 7 years
    Great helped me, but we need to sync and update both [ gradle and sdk tools versions]
  • Baxter
    Baxter about 7 years
    I was stuck on this until I saw your post I needed a specific older version of these. Great tip!
  • Steve Gelman
    Steve Gelman about 7 years
    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.
  • pjd
    pjd almost 7 years
    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
  • Sejal Baraiya
    Sejal Baraiya over 6 years
    Yes I agreed with your answer
  • Sagar Roy
    Sagar Roy over 6 years
    My current version is 3.0 i have tried your ways but its not solved :(
  • Tiago Simões
    Tiago Simões over 4 years
    Use latest version of contraint-layout
  • Louis
    Louis over 4 years
    I guess a simpler solution is expected.
  • Jesh Kundem
    Jesh Kundem over 4 years
    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