Could not find com.android.tools.build:gradle:3.0.0-alpha1 in circle ci
AndroidAndroid StudioGradleBuildCircleciAndroid Problem Overview
I update the gradle plugin to the latest : com.android.tools.build:gradle:3.0.0-alpha1
and this error occured :
export TERM="dumb"
if [ -e ./gradlew ]; then ./gradlew test;else gradle test;fi
FAILURE: Build failed with an exception.
What went wrong:
A problem occurred configuring root project 'Android-app'. Could not
resolve all dependencies for configuration ':classpath'. Could not
find com.android.tools.build:gradle:3.0.0-alpha1. Searched in the
following locations:
https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0-alpha1/gradle-3.0.0-alpha1.pom
https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0-alpha1/gradle-3.0.0-alpha1.jar
Required by:
Current circle.yml
dependencies:
pre:
- mkdir -p $ANDROID_HOME"/licenses"
- echo $ANDROID_SDK_LICENSE > $ANDROID_HOME"/licenses/android-sdk-license"
- source environmentSetup.sh && get_android_sdk_25
cache_directories:
- /usr/local/android-sdk-linux
- ~/.android
- ~/.gradle
override:
- ./gradlew dependencies || true
test:
post:
- mkdir -p $CIRCLE_TEST_REPORTS/junit/
- find . -type f -regex ".*/target/surefire-reports/.*xml" -exec cp {} $CIRCLE_TEST_REPORTS/junit/ \;
machine:
java:
version: oraclejdk8
Edit: My gradle file :
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha1'
classpath 'com.google.gms:google-services:3.0.0'
classpath "io.realm:realm-gradle-plugin:3.1.3"
}
}
allprojects {
repositories {
mavenCentral()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Android Solutions
Solution 1 - Android
Google have new maven repo
https://android-developers.googleblog.com/2017/10/android-studio-30.html > section Google's Maven Repository
https://developer.android.com/studio/preview/features/new-android-plugin-migration.html https://developer.android.com/studio/build/dependencies.html#google-maven
So add the dependency on maven repo:
buildscript {
repositories {
...
// You need to add the following repository to download the
// new plugin.
google() // new which replace https://maven.google.com
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.3' //Minimum supported Gradle version is 4.6.
}
}
Solution 2 - Android
For things to compile via command line I needed to include the maven repo in BOTH buildscript
and allprojects
.
root build.gradle
:
buildscript {
repositories {
jcenter()
maven { url 'https://maven.google.com' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha2'
...
}
}
allprojects {
repositories {
jcenter()
maven { url 'https://maven.google.com' }
}
}
It's needed in the buildscript
block to find the AGP, and in allprojects
block to find android.arch
and com.android.databinding
packages (and others)
UPDATE:
It looks like the new repo is just called google()
but I still needed to declare it in both places.
Solution 3 - Android
To synchronize all of the answers here and elsewhere:
> buildscript { > repositories { > google() > jcenter() > } > dependencies { > classpath 'com.android.tools.build:gradle:3.0.0' > > } }
Make your buildscript in build.gradle look like this. It finds all of them between google and jcenter. Only one of them will not find all of the dependencies as of this answer.
Solution 4 - Android
For Iranian people: We need use proxy or VPN to building app.
Reason: The boycott by Google's servers causes that you can't build app or upgrade your requirement.
Solution 5 - Android
mtrakal's solution worked fine.
Added to gradle.build:
buildscript {
repositories {
maven { url 'https://maven.google.com' }
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha2'
// NOTE: Do not place your application dependencies here;
// they belong in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
Then it automatically upgraded to alpha2.
Invalidate the caches and restarted all is fine.
File | Invalidate Caches / Restart
choose 'Invalidate & Restart'
Solution 6 - Android
I did this:
click SDk Manager:
Change in updates to Canary Channel, check and update it...
After go in build.gradle and change the compile version to 26.0.0-beta2:
After go in gradle/build.gradle and change dependencies classpath 'com.android.tools.build:gradle:3.0.0-alpha7':
After sync the project... It works to me! I hope I've helped... tks!
Solution 7 - Android
Make sure you add following line in your top level build.gradle and that should fix it.
maven { url 'https://maven.google.com' }
I got exact same error you mentioned above, once I added this entry everything worked.
Solution 8 - Android
For me I solved this error just by adding this line inside repository
maven { url 'https://maven.google.com' }
Solution 9 - Android
Update: Incredibly frustrating, but the Google redirect of the maven.google.com
repo seems to mess with loading the resources. If you instead set your repository to
maven { url 'https://dl.google.com/dl/android/maven2' }
the files will resolve. You can prove this out by attempting to get the fully qualified resource at https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.0.0-alpha1/gradle-3.0.0-alpha1.pom
3.0.0 Alpha
This is because currently the gradle:3.0.0-alpha1
is only being served via the new 'https://maven.google.com'
repository, but the site currently 404s at that location otherwise, being a public directory, you'd see a tree listing of all the files available by simply navigating to that location in your browser. When they resolve their outage, your CI build should pass immediately.
Solution 10 - Android
I find this at google: https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html
It mentiones that we need to
- Update Gradle version to gradle-4.1-all ( change
gradle-wrapper.properties
bydistributionUrl=\https\://services.gradle.org/distributions/gradle-4.1-all.zip
- Add google() to repositories
repositories { google() }
anddependencies { classpath 'com.android.tools.build:gradle:3.0.0-beta7' }
You may require to have Android Studio 3
Solution 11 - Android
Android Studio (Preview) sometimes recommends updating to a Gradle Plugin that is not available yet (did Google forget to publish it?). Such as today with
> 'com.android.tools.build:gradle:3.1.0-beta1'
I found I can see current versions of com.android.tools.build:gradle here, and then I just pick the newest:
https://dl.google.com/dl/android/maven2/index.html
I just found this beta1 gradle bug in the Android Bug Tracker. I also just learned Android Studio > Help Menu > Submit Feedback brought me to the bug tracker.
Found temporary solution at androiddev reddit for the 3.1.0-beta1 problem: Either roll back to Preview Canary 8, or switch to gradle plugin 3.0.1 until Canary 10 is released shortly.
Solution 12 - Android
My problem was that I forgot that I added a proxy in gradle.properties
in C:\Users\(current user)\.gradle
like:
systemProp.http.proxyHost=****
systemProp.http.proxyPort=8850
Solution 13 - Android
I have this problem when update android studio from 3.2 to 3.3 and test every answers that i none of them was working. at the end i enabled Maven repository and its work.
Solution 14 - Android
Just add this
buildscript {
repositories {
...
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
}
}
It works...Cheers!!!
Solution 15 - Android
My free advice is simply add mavenCentral() and google() in /build.gradle, or one of them how google advises on the official page. Should be something like this:
allprojects {
...
repositories {
mavenCentral()
...
google()
}
...
}