Could not resolve com.android.tools.build:gradle:3.2.1 - android

There is long time I had not developed any Android application (about 5 months) and now I have came back with nativescript. When I have created my first app using nativescript, I encountered this issue:
Executing before-shouldPrepare hook from
C:\Data\ProjectFiles\NativeScript\HeavenlyMinutes\hooks\before-shouldPrepare\nativescript-dev-webpack.js
Skipping prepare. Building project... Gradle build...
FAILURE: Build failed with an exception.
What went wrong: A problem occurred configuring root project 'HeavenlyMinutes'.
Could not resolve all artifacts for configuration ':classpath'.
Could not resolve com.android.tools.build:gradle:3.2.1.
Required by:
project :
Could not resolve com.android.tools.build:gradle:3.2.1.
Could not get resource 'https://plugins.gradle.org/m2/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.pom'.
Could not GET 'https://plugins.gradle.org/m2/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.pom'.
Connect to jcenter.bintray.com:443 [jcenter.bintray.com/108.168.243.150] failed: Connection timed out:
connect
Could not resolve com.android.tools.build:gradle:3.2.1.
Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.pom'.
Could not GET 'https://jcenter.bintray.com/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.pom'.
Connect to jcenter.bintray.com:443 [jcenter.bintray.com/108.168.243.150] failed: Connection timed out:
connect
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 48s Command gradlew.bat failed with exit code 1
So I have refered to my last projects created and developed using Android Studio. So the problem was there too. I have tested multiple configurations on gradle and for example two of them are mentioned below:
One
gradle.wrapper.properties
#Thu Sep 27 11:34:03 EEST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
build.gradle (project dependencies)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
maven { url 'https://maven.google.com' }
gradlePluginPortal()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
}
}
allprojects {
repositories {
google()
mavenCentral()
maven { url 'https://maven.google.com' }
gradlePluginPortal()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Two
gradle.wrapper.properties
#Thu Sep 27 11:34:03 EEST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
build.gradle (project dependencies)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
maven { url 'https://maven.google.com' }
gradlePluginPortal()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
}
}
allprojects {
repositories {
google()
mavenCentral()
maven { url 'https://maven.google.com' }
gradlePluginPortal()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
and none of them helped me. As my android projects were working before, I think the problem is somewhere else.
Note that the links https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.jar and https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.pom that are mentioned in the errors as unreachable links, are downloadable throw internet browser. So I think one possible solution will be to download them manually and put them somewhere in the project (but I have searched a lot how to do this and didn't find anything).

That was all about sanctions. I have tried some sanction-breaker and at last shecan solved my issue.
This answer will be useful only for Iranian users.

Finally, remove the proxy config in gradle.properties in .gradle folder, it words.Hope this answer will be useful.

Related

Android Studio update 3.1 start getting 502 Gate way gradle dependecies error

After update that SDK on my Jenkin server. I am getting below console error.
FAILURE: Build failed with an exception.
What went wrong:
A problem occurred configuring root project 'BuildDevelop'.
Could not resolve all files for configuration ':classpath'.
Could not resolve io.fabric.tools:gradle:1.+.
Required by:
project :
Could not resolve io.fabric.tools:gradle:1.+.
Failed to list versions for io.fabric.tools:gradle.
Could not list versions using M2 pattern 'https://jcenter.bintray.com/[organisation]/[module]/[revision]/[artifact]-revision.[ext]'.
Could not get resource 'https://jcenter.bintray.com/io/fabric/tools/gradle/'.
Could not GET 'https://jcenter.bintray.com/io/fabric/tools/gradle/'.
Read timed out
Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Problem is because bintray is down: http://status.bintray.com
Try this: https://stackoverflow.com/a/49510333/1607169
It's not so good idea, but you can revert com.android.tools.build:gradle:3.1.0 to 3.0.1
And
gradle-4.1-all.zip in distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip in gradle-wrapper.properties
Update your Project build gradle file with maven repo and proper jcenter like below and check:
repositories {
google()
jcenter()
jcenter { url "http://jcenter.bintray.com/" }
maven { url 'https://maven.fabric.io/public' }
maven { url "https://maven.google.com" }
maven { url "http://repo1.maven.org/maven2" }
}
I was running into a similar error and upgraded gradle to version 4.4 and that resolved the gradle sync issues.
You can follow this guide to upgrade, or go to File > Project Structure > Project and enter in 4.4 for the Gradle version
My projet gradle files looks like this:
buildscript {
ext.kotlin_version = '1.2.31'
ext.anko_version='0.10.4'
ext.supportLibVersion = '27.0.2'
repositories {
google()
maven { url 'http://repo1.maven.org/maven2' }
maven { url 'https://jitpack.io' }
maven {
url "https://maven.google.com"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.1.1'
}
}
allprojects {
repositories {
google()
maven { url 'http://repo1.maven.org/maven2' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

Could not find com.android.tools.build:gradle:3.0.1

When I try to build my project with gradle wrapper I get this error:
./gradlew
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> Could not resolve all files for configuration ':app:classpath'.
> Could not find com.android.tools.build:gradle:3.0.1.
Searched in the following locations:
https://maven.fabric.io/public/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom
https://maven.fabric.io/public/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.jar
https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom
https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.jar
Required by:
project :app
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
The same project builds OK in Android Studio.
I've already checked this and this but I'm using gradle wrapper version 4.1, have added google() repository and even tried setting android.enableAapt2=false. Any other tips? Thanks.
My root build.gradle file:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
My gradle-wrapper.properties file:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
UPDATE: Gabriele was right. I'd to add the repository also in the app/build.gradle file:
...
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
}
...
I guess that I was confused with this stament "To add one of these libraries to your build, include Google's Maven repository in your top-level build.gradle file" in here.
just wanted to leave an extra tip. When I installed Android Studio, I read somewhere that it was recommended to leave this configuration (with the '+' symbol)
build.gradle (project)
dependencies {
classpath 'com.android.tools.build:gradle:+'
.....
#more lines here
}
However, the project I am using uses an old version of gradle, and this line always requested the latest version. Took me a while to figure it out.
Check your proxy setting on Android Studio
File > Settings > Appearance
&
Behavior > System Settings > HTTP Proxy
Here was how I resolved the issue.
Change the root build.gradle file:
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
.....
//other codes here
}

Missing com.android.tools.build.gradle4.1 in Android Studio

Here is my build.gradle file:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
And here is gradle-wrapper:
#Fri Jan 12 02:39:29 EST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4.1-all.zip
The full error trace is here:
Error:FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'CryptoGallery'.
> Could not resolve all files for configuration ':classpath'.
> Could not find com.android.tools.build:gradle:4.1.
Searched in the following locations:
file:/home/xavi/android-studio/gradle/m2repository/com/android/tools/build/gradle/4.1/gradle-4.1.pom
file:/home/xavi/android-studio/gradle/m2repository/com/android/tools/build/gradle/4.1/gradle-4.1.jar
https://jcenter.bintray.com/com/android/tools/build/gradle/4.1/gradle-4.1.pom
https://jcenter.bintray.com/com/android/tools/build/gradle/4.1/gradle-4.1.jar
https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.1/gradle-4.1.pom
https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.1/gradle-4.1.jar
Required by:
project :
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 0s
I took a look in the directory /home/xavi/android-studio/gradle/m2repository/com/android/tools/build/gradle/4.1/ and saw that I do have a gradle 4.1 build, but it doesn't contain a simple .jar like the others do. It's the full download from the official gradle website. It contains many executables, but none labeled gradle-4.1.jar like the others.
Edit: After changing classpath to the correct line, android studio prompts me to update my gralde to 4.4.1, and I get a traceback.
Don't confuse gradle with the androd plugin for gradle.
Change:
classpath 'com.android.tools.build:gradle:4.1'
with:
classpath 'com.android.tools.build:gradle:3.0.1'
More info here.

Failed to build an existing application due to lack of jcenter certificate - blocked by gradle

I tried to build an andruid application using latest andruid studio
Seems that gradle is blocked due to lack of jcenter certificate in local machine certstore. My colleguee succeed to build it on his machine so the problem is in the configuration and not the application code
Configuration : andruid studio 3.0.1, gradle 3.0.0 ?, windows 7
I also tried to workaround ssl handshake by replacing jcenter() in build.gradle with
maven {
url "http://jcenter.bintray.com"
}
but it didn't solve the problem
My build.gradle below:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Gradle console:
Executing tasks: [assemble]
Configuration on demand is an incubating feature.
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'PDA'.
> Could not resolve all files for configuration ':classpath'.
> Could not resolve com.android.tools.build:gradle:3.0.0.
Required by:
project :
> Could not resolve com.android.tools.build:gradle:3.0.0.
> Could not get resource 'http://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0/gradle-3.0.0.pom'.
> Could not HEAD 'http://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0/gradle-3.0.0.pom'.
> Connect to repo.jfrog.org:80 [repo.jfrog.org/52.72.224.151, repo.jfrog.org/34.204.33.255] failed: Connection timed out: connect
The plugin v.3.x.x
classpath 'com.android.tools.build:gradle:3.0.0'
is not in jcenter.
You have to use the google maven repo.
buildscript {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
If you are using Android Studio 3 and gradle v.4.x you can use the google() shortcut
buildscript {
repositories {
...
google()
}
}
Besides as #GabrieleMariotti alreay said, that library will not be found at JCenter, you should not get Connection timed out: connect but a message that the library was not found.
Connection timed out: connect hints, that you cannot access that URL from your machine. My best guess is that you have to use some Proxy to access this URL that properly configured for your colleague, but not for you.

why can't android gradle find junit? why isn't it searching for it in remote repositories?

why isn't it searching for it in remote repositories?
after all i have at the top of my gradle script mavenCentral()
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
}
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "20.0.0"
and:
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':lvl-licensing')
testCompile 'junit:junit:4.12'
}
result is:
$ ./gradlew --info build
.
.
.
Creating configuration testReleaseProvided.
Creating configuration testReleaseWearApp.
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':myapp'.
> Could not resolve all dependencies for configuration ':myapp:_debugUnitTestCompile'.
> Could not find junit:junit:4.12.
Searched in the following locations:
file:/home/myuser/Android/Sdk/extras/android/m2repository/junit/junit/4.12/junit-4.12.pom
file:/home/myuser/Android/Sdk/extras/android/m2repository/junit/junit/4.12/junit-4.12.jar
file:/home/myuser/Android/Sdk/extras/google/m2repository/junit/junit/4.12/junit-4.12.pom
file:/home/myuser/Android/Sdk/extras/google/m2repository/junit/junit/4.12/junit-4.12.jar
Required by:
myapp-container:myapp:unspecified
* Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output.
BUILD FAILED
Total time: 7.023 secs
Stopped 0 compiler daemon(s).
I moved
repositories {
mavenCentral()
}
out of sectoin
buildScript {
}
and added to section buildScript {
the uri
repositories {
maven { url 'http://repo1.maven.org/maven2' }
}
and it resolved it..
gradle looks only in local places but not in mavenCentral() so i assume you either have no internetconnection to http://mavencentral.com or internetaccess is disabled.
does ping mavencentral.com work at the commandline?
does your settings.gradle contain this line which forbids gradle to use internet?
startParameter.offline=true
if you are using android studio: is settings/compiler/gradle/OfflineMode disabled?
I checked http://search.maven.org/#artifactdetails|junit|junit|4.12|jar that 'junit:junit:4.12' is available at mavencentral.com
The solution described by #Jas worked for me. But, since I had trouble adjusting build.gradle, I decided to post an answer with the complete change. This is how my build.gradle looks like ath the end:
buildscript {
repositories {
maven { url 'http://repo1.maven.org/maven2' }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
}
}
repositories {
maven { url 'http://repo1.maven.org/maven2' }
}
allprojects {
repositories {
maven { url 'http://repo1.maven.org/maven2' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I set this in my Android studio project. and it worked for me.
Open Model Settings > Project > Default Library Repository > jcenter
I could not set "Model Settings > Project > Default Library Repository > jcenter" as text field was some how non editable.
so added following in build.gradle and it solved my problem
repositories {
jcenter()
}
This solved my problem
You need internet connection -at least first time- to build project first time correctly (i really don't know why) !!!
so, to avoid that you may try download JUnit (required library) from here and add it manually to your application into ~[YourAppFolder]\app\libs
then rebuild your app.

Categories

Resources