Gradle Sync failed could not find constraint-layout:1.0.0-alpha2
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.
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.
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
Solution 5
-
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'
}
TooCool
Updated on September 22, 2021Comments
-
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 about 8 yearsBe careful with using 2.2.0-alpha3 there is a bug with Toolbar on Android 4.x stackoverflow.com/questions/37812115/…
-
Chris almost 8 yearsThanks this worked for me. Gradle updated itself after popup but not the constraint dependency
-
Antimonit over 7 yearsFor those who have these libraries installed but gradle is still complaining, check
jmartinalonso
's answer below. It is extending this answer. -
Sébastien over 7 yearsNote:
Preferences
is actuallyFile
>Settings
on Windows. -
Hareendra Chamara Philips over 7 yearsIn 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. -
Syed Raheem Uddin over 7 yearsGreat helped me, but we need to sync and update both [ gradle and sdk tools versions]
-
Baxter about 7 yearsI was stuck on this until I saw your post I needed a specific older version of these. Great tip!
-
Steve Gelman about 7 yearsI'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 almost 7 yearsAs 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 over 6 yearsYes I agreed with your answer
-
Sagar Roy over 6 yearsMy current version is 3.0 i have tried your ways but its not solved :(
-
Tiago Simões over 4 yearsUse latest version of contraint-layout
-
Louis over 4 yearsI guess a simpler solution is expected.
-
Jesh Kundem over 4 yearsWhere 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