I have already created one project and gradle sync worked successfully.
When I try to create another project it fails and gives the error message that
Gradle '<ProjectName>' project refresh failed
Error:Cause: peer not authenticated.
I have setup SDK, gradle gave gradle VM options
-Dhttp.proxyHost=<proxy.address> -Dhttp.proxyPort=<port> -Dhttp.proxyUser=<username> -Dhttp.proxyPassword=<password>
And in HTTP proxy tab also I have given the correct options.
Can anyone help me?
This was the solution that worked for me. Posting here in case it helps someone.
Gradle version was not correct in project build.gradle file.
I had
classpath 'com.android.tools.build:gradle:1.0.0'
but this needed to be
classpath 'com.android.tools.build:gradle:2.1.0'
Note:
This should be updated to the newest version of gradle tools which can be found here
Android Studio also recommends the latest plugin version.
DO NOT change your package source to http instead of https. Stop using these workarounds and fix the root cause.
Do you want to have a driveby exploit in your app? Because that's how you get a driveby exploit in your app!
The source of this problem Certificate Authority keystore. Somehow dpkg seems to try to build the Java keystore (/etc/ssl/certs/java/cacerts) before it actually installs Java, which the the tool to build the store requires. The result is an empty store:
To fix this, properly build the keystore with all trusted CA certificates.
Run this with sudo:
sudo rm /etc/ssl/certs/java/cacerts
sudo /var/lib/dpkg/info/ca-certificates-java.postinst configure
You should see a long list of added certificates (*.pem) and finally a “done”.
Re-sync the project using gradle, and all will download. Don't forget to turn off the http override if you've set it!
Source: https://justus.berlin/2015/01/connection-problems-with-ssltls-peers-in-java-on-ubuntu-server-14-12-with-fix/
This error says that you're trying to connect using HTTPS protocol, but your client unable to validate server's certificate - usually because it is self signed.
Connect to https://jcenter.bintray.com with your browser, and check the certificate chain. The root certificate should be issued by GeoTrust Global CA. If it's not the case, your Internet Provider or your employer perform MITM to your HTTPS connections.
If you trust them, the simple workaround will be to add those self-signed certificates into JDK's cacerts keystore. Examples for how to do that: Windows; Linux/Mac.
Usually this error happens when you're under a company proxy. My solution on MAC was this:
Identify the Certificate is being used by your https connections
Open Key Chain Tools (cmd+space key chain)
Identify the certificate found up and export it to certificate.cer file
Open the terminal and navigate to your JAVA JRE security folder:
cd /Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/security
Import the certificate with the following command:
sudo keytool -import -alias somealias -file /PATH_TO_EXPORTED_CERTIFICATE/certificate.cer -keystore cacerts -storepass changeit
That is done. Open Android Studio and it will fix the gradle build.
It's a dumb answer, but what fixed this for me was restarting Android Studio.
I was using Charles Proxy off and on, I suspect that had something to do with the cause of the error. Closed the proxy and restarted android studio, and it worked. Figured I would post because sometimes the answer is so simple we forget to even try it.
I closed my studio and when I re-opened the project, I got a window to enter proxy information. In that, I had to check the check box which said "Enable HTTPS proxy" and that worked for me!
please change the gradle build tools version first. You need to update the build tools version. Still not working, create a new project and check the gradle file details. 1.5.0 is the latest version I have installed.
classpath 'com.android.tools.build:gradle:1.5.0'
After meddling with it, and following Schizo's answer (you should follow it also), and it not working. I realized Android Studio was using java-7-openjdk but I added a certificate to java-8-openjdk, so it didn't work until I changed it to the openJDK 8 in Project Structure, so be sure that you check that also, in case it's not working for you.
THis fixed it for me after wasting lot of time trying various solutions:
Check the dependencies -> classpath in build.gradle file of project
dependencies {
classpath 'com.android.tools.build:gradle:2.10'
}
Changed this to classpath 'com.android.tools.build:gradle:2.0.0-rc1 in my case to fix the issue . To know the correct version to be used, made a new project and checked the build.gradle file .
Hope this helps.
dependencies {
classpath 'com.android.tools.build:gradle:1.0.1'
}
I change classpath com.android.tools.build:gradle:1.1.3' to com.android.tools.build:gradle:1.0.0
There is one more small change can help you in
gradle-wrapper.properties
Change
distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
To
distributionUrl=https://services.gradle.org/distributions/gradle-2.4-all.zip
Sync the project once you did the change
I also faced the same issue and the problem was related to certificates.
1: So first step is go to Build-> Clean Project. It will give you the details about the error.
2: Copy URL which is failing from the stack-trace. For eg build is failed to download some file, stack-trace will have the information of the URL.
3: Open the url in a browser, if you are able to open it that means your proxy settings are fine but java is unable to trust the source to download it.
4: So you need to copy the certificate manually and put in the jre certificates. And rebuild should resolve the problem.
5: Or if you have the latest jre verison, it might solve the problem.
As this occurs I using Ubuntu: When I changed version on android studio 2.0 9 preview beta 1.
How do I fix my gradle.
Simply created a new project in android studio and then went in and saw build.grandle version gradle in my case:
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-beta1'
}
and replace in my project.
I hope it helps others.
In my case I had to download the latest Java SDK and then change the JDK location in the project to the downloaded JDK. Apparently something was wrong with the current JDK (had some warning from my virus scanner about this)
In case this helps someone, I had the same issue and even though I set the proxy through the studio settings ( which adds the values of systemProp.http.proxyHost and systemProp.http.proxyHost to gradle.properties), https proxy was not set, so I added this in gradle.properties
systemProp.https.proxyHost = <your proxy host>
systemProp.https.proxyPort = <your proxy port>
and problem solved!
answer share from here https://stackoverflow.com/a/37962441/4030497
in case when there are some problems with internet,
try to add a line
54.231.14.232 s3.amazonaws.com
to your /etc/hosts (..\Windows\System32\drivers\etc\hosts)
Make sure you have specified latest gradle version in build.gradle file and latest distributionUrl in gradle-wrapper.properties file. Check network connetivity is proper or not [ Network connection should be without firewall/other settings which can stop upgrading gradle]
distributionUrl=http://services.gradle.org/distributions/gradle-2.1-all.zip
keep the http://
I have the same problem and salve it,My conduction is I define the HTTP proxy and I use agent to connect the server. Actually, you don't need proxy to connect jcenter
Changing my build.gradle to shown below worked.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Update your gradle to the latest version .
It works perfectly .
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
I hope it helps.
May be sometimes your app use Crashlytic bundle in your graddle
And your network cannot resolve Crashlytic library. In another way, may be others lib can cause problem. Please check your internet can access and grep those libs.
So it return an error that
"Error:Cause: peer not authenticated."
For me, I solve this problem by comment code that evolved crashlytics lib all
and compile again ---> this problem drain my working time to 4 hrs to know and clear it.
T ^ T
Wish all of us safe from this problem.
Related
Could not install Gradle distribution from 'https://services.gradle.org/distributions/gradle-5.4.1-all.zip'
I have just installed Android Studio 3.5 on windows and then created new project then above exception occurs.
I have searched on google regarding the above error but none resolved.
Below are the links which I have tried but none worked
Could not install Gradle distribution from 'https://services.gradle.org/distributions/gradle-2.1-all.zip'
Eclipse -Could not install Gradle distribution from 'https://services.gradle.org/distributions/gradle-2.1-bin.zip'
Is this issue is with Antivirus which is installed in local machine ?.I am just guessing, is this because of Antivirus ?
I was trying with this since 3 days.Please help me on this.Any help would be appreciated.
I had the same problem and eventually I figured out that running Android Studio as administrator solves it. You can at least give it a try!
Steps to fix:
Close Android studio.
Right click on launcher icon of Android Studio
Click on "Run as administrator"
It will run like charm.
Goto gradle-wrapper
and see carefully the URL
distributionUrl=https \ ://services.gradle.org/distributions/gradle-6.1.1-all.zip
now correct the https \ :// to https://
and click on "try again upside."
it will took download the file and run automatically.
And after successful run promote thi$ answer.
Open your gradle-wrapper.properties and modify your distributionUrl to point to gradle-5.4.1-all.zip, i.e.
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
Change classpath to 3.5.0
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
...
}
}
Close your Android Studio, whatever version you are using.
Start it again with administrative log in.
Android Studio will detect what needs to be updated or downloaded.
Automatically it will resolve the issue.
5.5.1 is out now, try upgrading to that using ./gradlew wrapper --gradle-version=5.5.1 and see if that makes a difference. This is preferable to editing any Gradle files manually.
For me, i re-downloaded the new and latest version of android studio, installed it full.
that solved the problem for me.
download gradle 5.4.1 manually from https://downloads.gradle-dn.com/distributions/gradle-5.4.1-all.zip and extract the file and please it in .gralde file in your android project.
then restart the android studio
In case the complete error message is something like:
Could not install Gradle distribution from 'https://services.gradle.org/distributions/gradle-5.4.1-all.zip'.
error in opening zip file
You need to delete two files( under your .gradle/wrapper/dists/* directory):
gradle-5.4.1-all.zip
gradle-5.4.1-all.zip.lck
Then try again to download dependencies or upgrade.
Sometimes it might be due to the broken files in .gradle file.
This is an hidden folder in installation directory. Remove the dists folder from this location and go to File -> Invalidate Caches/Restarts.
For me it helped.
rm -rf .gradle/wrapper/dists
I got the same issue in new "Android Studio Bumblebee | 2021.1.1" release. Like "Could not install Gradle distribution from 'https://services.gradle.org/distributions/gradle-gradle-7.2-all.zip'".
I did the following steps,
Step 1:
I did the same steps mentioned here- https://stackoverflow.com/a/59420289/1122622 ,
Like,
Close Android studio.
Right click on launcher icon of Android Studio
Click on "Run as administrator".
Step 2:
Also, verified with official gradle URL- https://services.gradle.org/distributions/ , the given link was right or wrong.
Step 3:
Don't forget to restart the Android Studio once the gradle download was completed.
After all the above 3 steps your issue will be resolved for sure and it will be applicable for upcoming gradle upgrade issue.
Note: Also verify "Do not build Gradle task list during Gradle sync" is enabled, in File->Settings->Experimental->Gradle.
Check if you accidently changed Gradle user home path. Goto Preference in Android studio, search for gradle and check gradle user home path.
It should be like:
/Users/mac/.gradle/
From: classpath 'com.android.tools.build:gradle:3.2.1'
To: classpath 'com.android.tools.build:gradle:3.5.0'
And the gradle version:
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
GL
I got this error while opening a very old project, the reason was that it was trying to fetch over http and not https. Update the distributionUrl path to https in the path \<project directory\>\gradle\wrapper\gradle-wrapper.properties and run the android studio in admin mode.
Please check the value of checksum that you are using in the 'gradle-wrapper.properties' for the version that you are using. It could also be a problem and you get the same error.
Find the value of checksum for the gradle versions at below link:
https://gradle.org/release-checksums/
1-Create new project on android studio
2-open the new project gradle-wrapper.properties
3-copie the new distributionUrl
4-paste it on your own project
5-click on try again
this will correct error
My solution is just turn on the offline mode, and give the wrong version value like "https://services.gradle.org/distributions/gradle-7.2.1-all.zip", it shows the error like no offline package available and asks me to try in offline mode, then just replace with the exact correct value and turn off the offline mode, then click try again, it is worked for me.
Change this distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
to distributionUrl=https://services.gradle.org/distributions/gradle-6.5-bin.zip
Then click file, in the dropdown click invalidate Caches
Worked for me these steps
Goto->
gradle-wrapper.properties
Update this (backward slash after https)
distributionUrl=https://services.gradle.org/distributions/gradle-7.0.2-bin.zip
to
distributionUrl=https://services.gradle.org/distributions/gradle-7.0.2-bin.zip
and
Sync the project or click on "try again" option appearing on top
and restart the Android studio, it will automatically download required files.
Just find gradle-wrapper.properties in your IDE. And change version in
distributionUrl=https://services.gradle.org/distributions/gradle-5.4.1-all.zip' to distributionUrl=https://services.gradle.org/distributions/gradle-6.8.3-bin.zip
Ensure the Network connection is very good and keep on retrying. Sometimes i tap retry few times before it works.
I am not able to work with the gradle dependencies on the MAC.
I am getting this error :
Could not GET
'http://jcenter.bintray.com/com/android/tools/build/gradle/2.0.0/gradle-2.0.0.pom'. Received status code 407 from server: Proxy Authentication Required
Its a proxy issue.
I have though set the proxy in the gradle.properties as well and in the Settings>Https as well.
I am able to download the SDK but not the gradle plugin.
If i try to click the link in the error , I get redirected to the gradle site (on Safari) and 1Kb of pom file gets downloaded itself.
I am wondering that somehow the safari application has the correct setting for the proxy thats why it is able to downloaded the pom file
but from within the android studio , somewhere authentication is failing and hence it is failing.
Is there any other place i have to put the proxy or any test to test the correct way of working the proxy from within the Android Studio.
already added jcenter in build.gradle :
jcenter() {
url "http://jcenter.bintray.com/"
}
I have already checked the "check connection" by providing the url(which came in the error) ->
and it says connection successfull.
WHats the hidden mystery here to solve this issue?
thanks in advance !
Add jcenter() to your list of repositories and Gradle should find version 2.0.0
I downloaded Android Studio 3.0 and I started following along building my first app tutorial. But Gradle threw errors like:
Could not resolve com.android.support:appcompat-v7:26.1.0.
I searched on SO for similar problems like this and that, but none of them helps me.
Eventually I figured out that I'm using a proxy for Android Studio:
To resolve the error, I have to implement the proxy for Gradle too, by adding these lines to gradle.properties file:
systemProp.http.proxyHost=127.0.0.1
systemProp.http.nonProxyHosts=localhost, 127.0.0.1
org.gradle.jvmargs=-Xmx1536m
systemProp.http.proxyPort=8118
systemProp.https.proxyHost=127.0.0.1
systemProp.https.nonProxyHosts=localhost, 127.0.0.1
systemProp.https.proxyPort=8118
After adding the above statements to gradle.properties, the error got resolved. Note that both HTTP and HTTPS proxies need to be added to Gradle properties
I had the same error. Tried a lot of stackoverflow links but none of them helped until this one. The problem in my case was due to https proxy settings which were not there in the gradle.properties file. I included it and it worked.
For android studio 3, inside build.gradle file of your project you have this:
allprojects {
repositories {
jcenter()
google()
}
}
The jcenter() runs over https and hence if you are building in a network(in most cases company network) which uses https proxy, and you forgot to include it in your gradle.properties file, then you are likely to face the issue. You may feel that gradle is behaving weird but its not. Its only missing the proper network configuration. Even offline build settings wont work since it still needs jcenter() to download files for the first time you are building an app in latest Android Studio.
I included my https proxy settings in gradle.properties like this:
systemProp.https.proxyHost=<proxy server address>
systemProp.https.nonProxyHosts=localhost, 127.0.0.1
systemProp.https.proxyPort=<port number>
I've just updated to Android Studio 1.3, opened an existing project I was working on, tried to run it. Gradle just gets stuck at the "Resolve dependencies':app_debugCompile'", I tried to wait, I waited for over an hour and nothing happened.
How can I solve it to get my app running?
If you are using proxy, it seems https proxy server setting is not correctly done in Android studio 1.3.
You can set https proxy server manually in gradle.properties,
systemProp.https.proxyHost=proxy.server.address
systemProp.https.proxyPort=8080
see Gradle Sync fails in Android studio 1.3 and gradle behind proxy in Android Studio 1.3.
How can I solve it to get my app running?
Start by identifying the problem more precisely. To do so, run gradle from the command line in the root directory of your project :
./gradlew --debug clean build
The --debug argument will simply enable the debug log level and hopefully providing useful information to understand where/why it is hanging.
I face this problem in linux and my problem solved after installing these dependencies on fedora :
sudo dnf install glibc.i686 zlib.i686 libstdc++-devel.i686
I had this problem.Just see this page. Solution is here
Solution :
Make sure you have latest stable version ( current 2.0.0 )
Make sure your gradle version is 2.0.0 in build.gradle ( classpath 'com.android.tools.build:gradle:2.0.0')
Final step and most important one is change your jcenter() to mavenCentral()
So you can easily add new dependency and sync project under 3sec !
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Go to app > Right Click on it > Open Module Settings>Change build tool version to 22.0.1
Try again after restarting your Android Studio
I've just encountered this issue in the OP, in my case it was taking over 20min just to get gradle build going. Getting stuck at the "Resolve dependencies':app_debugCompile'" as well.
I'm still relatively new to Stackoverflow so I can't up-vote yet. But what I can tell you is that if your behind a web proxy like I am and you've just updated to Android 1.3.1 you will probably notice this issue immediately. I already had my companies web proxy in the IDE settngs and yes there is something not ok with the 1.3.1 update. As corochann posted you have to add the proxy info to the gradle.properties of your project. Once I actually did this I noticed the difference immediately. Going forward until its resolved you'll probably have to add this to each project if your behind a web proxy and running 1.3.1. I have another machine at home that isn't behind a proxy and is running Android Studio version before 1.3.0 and had no issues. Hope this helps!!
I have a Gradle file that runs the tests. It does not build anything. All it has is a unzip task that extracts all jars in a Gradle configuration into a particular directory and then runs the task of type Test. This test task points the testClasses directory to the location where the previous copy task has extracted the configuration into.
My build fails with the error message:
Problems reading data from Binary store
When I run 'gradle dependencies' it does not show any error/warning
When I run the copy task individually, it runs very well fine.
Only when I run everything it fails with error :
> Could not resolve all dependencies for configuration ':testConfig'.$
> Problems reading data from Binary store in /tmp/gradle8793563212642185736.bin (exist: false)$
I see the file /tmp/gradle8793563212642185736.bin does not exist. What could be the reason for this?
I solved upgrading following packages to last version (06/02/2021), so:
project app-level build.gradle file:
com.google.firebase:firebase-analytics:17.2.2
to
com.google.firebase:firebase-analytics:18.0.2
Project-level build.gradle file:
com.google.gms:google-services:4.3.3
to
com.google.gms:google-services:4.3.5
In my case setting org.gradle.parallel=false flag fixes the issue, but it's not a solution for my project, flag increase CI build time from ~15min to ~45min.
Turns out it was just a network problem for me. Gradle just needed to connect to the internet.
It happened with Flutter development in my case. Apparently, it is not an actual issue and there is no magic fix. Cleaning build file with "Flutter clean" and restarting the command line executer window solved the issue.
I was working with version 5.x earlier and then I upgraded to 6.0.1 and it resolved the issue.
this is how you can upgrade
cd android
./gradlew clean
./gradlew wrapper --gradle-version 6.0.1
./gradlew -v # to download the new version
cd ..
flutter clean
flutter run # might take 15 - 20mins for the first time
There are mainly a few steps to solve this problem.
Go to gradle.properties and set org.gradle.parallel=false and sync. Make sure your sync gradle offline option is off
Start the build with this option. If it's a big project setting org.gradle.parallel=false will take a long time.
Cancel the build repeat the steps setting org.gradle.parallel=true.
Also do not turn on offline build
This solution worked in my flutter project. I solved it by making these changes:
In android level build.gradle file, replace classpath 'com.android.tools.build:gradle:3.5.4' with classpath 'com.android.tools.build:gradle:4.0.1' (basically upgrade the version from 3.5.4 to 4.0.1)
In gradle-wrapper.properties file, replace distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip with distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip (upgrade from 5.6.2 to 6.1.1)
and if you have added classpath 'com.google.gms:google-services:4.3.3' to android level build.gradle file, replace that too with classpath 'com.google.gms:google-services:4.3.5' (upgrade from 4.3.3 to 4.3.5)
In my case the writing problem was there was no enough storage to build the app so I needed to restart my Mac and it finished building successfully.
I know am too late but it might help someone in the future so
Start by upgrading Gradle to the latest version.
Binary store issues reported to GitHub are often fixed right away, especially if they include a Minimal, Reproducible Example.
If upgrading didn't work, it can be useful to run the task again with Performance options disabled:
--no-parallel
--no-configure-on-demand
Next please find an existing issue or open a new one so it can be fixed in future versions. These things are all helpful:
Minimal, Reproducible Example
Build Scan
Smallest change that introduced the problem (e.g. worked on 5.5, but not 5.6)
I ended up here after publishing an artifact to mavenLocal().
I tried a lot but in the end what helped me was:
Upgrading gradle from 6.3 to 6.9
./gradlew wrapper --gradle-version 6.9
Hope this saves me half an hour next time this occurs.
Thanks to Cedric's hint, stopping gradle offline mode and make it online, fixed the issue for me