2

After installing Android Studio 3.1.2 for the first time on his Windows 7 corporate laptop and loading a default project, the user discovers that studio will not properly Gradle Sync. This occurs when gradle attempts to download the Android Studio gradle plugin 3.1.2 as a part of the Configure Project subtask. The error displays as connection reset after spending a long time attempting to download the plugin from several repositories.

Visual display of the problem:

enter image description here

Android Studio had previously downloaded gradle 4.4 itself with no issues, so that suggests that Android Studio has internet connectivity and the proper rights within the gradle home directory which is located in the default location (i.e the users folder). Deleting the .gradle folder and letting Android Studio redownload it is always successful, but never helpful (Common solution for project configuration).

Switching between using internal JRE and external JDK (java 1.8) does not result in any changes. Gradle is not running offline. Running the gradle wrapper from commandline results in the same problems. Pointing to an external gradle distribution (in this case I pointed to gradle 4.7) does not seem to help. All other settings are defaults. Permissions do not seem to be the problem since the same problems crop up when running android studio in admin mode. Invalidating the cache and restarting the application is unhelpful.

A common solution mentioned by other users for synch problems is to add alternative repos to the gradle build file. This solution has no success for this particular problem.

The simple gradle build file:

enter image description here

Another solution mentioned by other users is to alter proxy settings. Given that the laptop is of corporate origin, this might make some sense. Unfortunately, given that android studio is able to download gradle by itself, this does not seem to be the case. Also if proxying was the issue, a different connection failure message would likely appear (Proxy Problems Solution).

Has anyone experienced this problem, and do you have a solution to get android studio synching successfully?

Arnab
  • 4,216
  • 2
  • 28
  • 50
Annoth
  • 41
  • 1
  • 7

2 Answers2

2

I also have the same problems as you,Now I have solved it.

The following are the steps to be solved

  1. exit androidStudio
  2. delete the .gradle folder eg: C:\Users{userName}}.gradle
  3. restart androidStudio and wait a moment
zhaozhenye
  • 21
  • 1
  • Unfortunately, this do not solve my problem. I tried deleting all the temporary folders, .AndroidStudio3.1, .gradle, .m2, .p2 and restarting. – Annoth May 08 '18 at 14:28
0

This worked for me:

File >> Settings >> Build, Execution, Deployment >> Gradle Build >> Android Studio

Then tick Enable embedded Maven repository

PrakashG
  • 1,642
  • 5
  • 20
  • 30