'Android studio Gradle sync and build error

I am new to android studio and gradle and i got AS 0.5. I downloaded the 0.8.1 update package and updated by deleting the installed files and copying the update files to the program files folder. It runs correctly but when i try to sync gradle, i get this error. It's really frustrating because i have an extremely slow internet connection and i have tried deleting the .gradle file and trying again wit no luck. Any help will be appreciated. My ADT is currently messed up because of the r23 bug. I thought AS will offer a way out and now I'm stuck again.

Error:Unable to start the daemon process.
This problem might be caused by incorrect configuration of the daemon.
For example, an unrecognized jvm option is used.
Please refer to the user guide chapter on the daemon at http://gradle.org/docs/1.12/userguide/gradle_daemon.html

Please read below process output to find out more:

18:44:13.593 [main] DEBUG o.g.l.daemon.bootstrap.DaemonMain - Assuming the daemon was started with following jvm opts: [-XX:MaxPermSize=256m, -XX:+HeapDumpOnOutOfMemoryError, -Xmx1024m, -Dfile.encoding=windows-1252]

FAILURE: Build failed with an exception.

* What went wrong:
Could not create service of type DaemonContext using DaemonServices.createDaemonContext().

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option  to get more log output.


Solution 1:[1]

Run Android Studio as administrator. It fixed the problem for me.

Solution 2:[2]

For anyone encountering this error on Linux (Ubuntu 14.04 in my case), I found the problem was that the /tmp directory was mounted with a "noexec" flag, preventing AS from starting Gradle.

After removing the "noexec" flag in /etc/fstab and a restart, AS was able to run Gradle properly:

jayne@serenity:~$ grep tmpfs /etc/fstab
tmpfs /tmp tmpfs mode=1777,nosuid 0 0

Many thanks to: www.fernandezsansalvador.es (and Google Translate)

Solution 3:[3]

Upgrade the gradle in your gradle-wrapper.properties to 2.5 from 2.1

distributionUrl=https\://services.gradle.org/distributions/gradle-2.5-rc-1-all.zip

This should fix the problem (which I assume is caused by studio trying to run gradle daemon on a root port <1024)

You can also run the studio as Administrator but if you already have the project setup then you would have to re-import and reconfigure studio (because root/Admin is a new user for studio)

Solution 4:[4]

assuming that you had as 6,x alpha you need to download the as beta 8.0 and than update to 8.1 as alpha and beta are not compatible

Solution 5:[5]

Try change the JDK version. I downgraded my version from 11 to 1.8 and it worked.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Taryn
Solution 2
Solution 3 Ganesh Krishnan
Solution 4 Fred Grott
Solution 5 Qing