JonathanLu
JonathanLu

Reputation: 171

Gradle sync failed: The first result from the daemon was empty. Most likely the process died immediately after connection

I just recently downloaded an Android Studio and installed it on my PC. But When I try to set up my first project "hello world", it always brings up the following:

Gradle sync failed: The first result from the daemon was empty. Most likely the process died immediately after connection.
Consult IDE log for more details (Help | Show Log)

Upvotes: 17

Views: 13761

Answers (15)

bradpin
bradpin

Reputation: 9

In my case, after trying all of the above, I realised:

  • I was using the wifi network @ brandname coffeshop which had authentification.
  • I also had Global Gradle settings:"Offline work" activated (Settings/Build,Execution,Deployment/Gradle/Global Gradle settings).

I switched to my phone hotspot, and deactivated the Offline work.

Now (after 1 and a half hours) my builds are running again.

Upvotes: 0

Lincy David
Lincy David

Reputation: 195

  1. Just look gradle-wrapper.properties from project opened inside android studio. distributionUrl=https://services.gradle.org/distributions/gradle-2.10-all.zip

  2. Now to go C:\Users.gradle\wrapper\dists there you can see different gradle versions.I'm my case I had a latest version gradle-2.11-all.

  3. Now go to android studio - File ->invalidate Cache/Restart

  4. Now edit gradle-wrapper.properties and add latest version of gradle there.After updation my gradle-wrapper.properties looked like this.

    distributionBase=GRADLE_USER_HOME
    distributionPath=wrapper/dists
    zipStoreBase=GRADLE_USER_HOME
    zipStorePath=wrapper/dists
    distributionUrl=https\://services.gradle.org/distributions/gradle-2.11-all.zip
    

Now Sync project. That's it.

Upvotes: 0

Casper
Casper

Reputation: 121

I had the same issue in IntelliJ. I fixed it by running the following command in the terminal:

./gradlew --stop

Upvotes: 0

Aadhitya
Aadhitya

Reputation: 83

Now the answers given before me are quite technical, mine is the exact opposite. What worked for me everytime this issue came in, was checking my internet connection. Once I was connected to my mobile hotspot instead of my regular wifi, and I was getting this issue. I have no idea why, but reconnecting to my wifi fixed it. I didnt restart the IDE or anything. I'm sure there is some technical explanation behind this, but as long as it works, I am fine lol.

Upvotes: -2

qwertzguy
qwertzguy

Reputation: 17765

To find the actual issue:

You'll need to look into the output logs of your daemons in: ~/.gradle/daemon/X.X.X/daemon-XXXXXXX.out.log. Then search for line with [ERROR].

One liner: grep '\[ERROR\]' ~/.gradle/daemon/*/daemon*.out.log

Upvotes: 0

Akbolat SSS
Akbolat SSS

Reputation: 2071

Sitting on MacOs 10.14.6 tried these things:

  • Close/Open Android Studio
  • Invalidate caches/Restart
  • Download latest NDK from Tools/SDK Manager
  • Delete all NDKs from mac

Nothing helped. The only worked is reset Mac

Still dont know what caused this behaviour

Upvotes: 0

Prasanna Narshim
Prasanna Narshim

Reputation: 798

I just followed the other answer but I couldn't find the registry.bin.lock file in mac, then I just deleted the following folders,'

  • /Users/../.gradle/caches

  • /Users/../.gradle/daemon

then do a File-> Invalidate Caches/Restart. The above folders should be updated during Gradle Sync, just say yes if it throws popup for gradle update

Please take a backup of these folders before deleting.

Upvotes: 0

Muhammad Abrar
Muhammad Abrar

Reputation: 21

First Credit Goes to Kali Kimanzi .. for this answer [Windows 7-10]

go to C:/Users/.../.gradle/daemon/ open any of the folders in daemon look for this file registry.bin.lock delete it now go sync the gradle in Android Studio and your problem should be solved

A little update for noobs .. C:/Users//.gradle/daemon/ and instead of deleting the file registry.bin.lock just rename it to registry.bin.lock.backup just incase .. though the file itself might be corrupt

Upvotes: 1

Deep Shah
Deep Shah

Reputation: 15

If any of the cases mentioned here didn't meet the expectations, there may be something wrong with your dnsapi.dll file in your windows which several software use (It happens in rare cases but give it a try).

Close Android Studio and try running a program(software) that uses this dnsapi.dll file. For ex. try running BitTorrent. If it says 'DNSapi.dll missing from your computer', then the studio error is most probably because of the corrupted/missing dll file.

Try running following command on your command prompt.(Make sure you have a good internet connection)

DISM.exe /Online /Cleanup-image /Restorehealth

And then run the system file checker.

sfc /scannow

It would take some time. Now run Android studio.

Upvotes: 0

mohammed youser sawwas
mohammed youser sawwas

Reputation: 621

I was facing the same problem in Android Studio 3.However, none of the solutions mentioned here worked for me.With only 4 GB of RAM available ,the only thing worked for me was just changing the value specified for JVM args which is related to RAM in gradle.properties file like the following:

# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.

org.gradle.jvmargs=-Xmx1536m

to:

org.gradle.jvmargs=-Xmx512m

then File | Invalidate Caches/Restart--> Invalidate and Restart

This really did the trick.

Upvotes: 6

Anthony Kimanzi
Anthony Kimanzi

Reputation: 856

I solved the problem by doing the following:

  1. go to C:/Users/.../.gradle/daemon/
  2. open any of the folders in daemon
  3. look for this file registry.bin.lock
  4. delete it
  5. now go sync the gradle in Android Studio and your problem will be solved

Success

Upvotes: 70

Jupitor Apps
Jupitor Apps

Reputation: 31

Today I faced the same issue. File-Invalidate & Restart worked for me.

Upvotes: 1

Tolga DURAN
Tolga DURAN

Reputation: 51

Solution: The only workaround for me is to use ipv6 instead of ipv4 : in bin/studio.vmoptions or bin/studio64.vmoptions (depending on if you are in 32 or 64 bits), change the line

  • Djava.net.preferIPv4Stack=true

by

  • Djava.net.preferIPv6Stack=true

Upvotes: 0

Sabbir Ahmed
Sabbir Ahmed

Reputation: 1

I also faced the same problem.I exited from Android Studio and re-opened Android Studio.In my case,The Problem Solved Then.You Can Try this Procedure.

Upvotes: 0

Pushkaraj Joshi
Pushkaraj Joshi

Reputation: 159

Guess what, I just faced this issue and I solved it. I did something very risky, but it looks like the fault is in the gradle cache directory. If you are using windows the dir. will be at C:\Users\username.....gradle\caches and deamon <- will be the directory where all the gradle versions are stored. Delete the latest particular version from the Cache as well as the Deamon folder. Next time your project syncs, AS will automatically generate the two files. Also
3.Now go to android studio - File ->invalidate Cache/Restart 4.Now edit gradle-wrapper.properties and add latest version of gradle there.After updation my gradle-wrapper.properties looked like this. From the above answer. This worked for me

Upvotes: 3

Related Questions