Android Studio Gradle task stuck - android

I've installed android studio. It's Gradle process hasn't finish after 2 hours. What should I do for ending this process?

Problem is with your internet connection because of which gradle is failing to resolve the dependencies.
make sure you are connected.
make sure if you are behind proxy server the proxy settings are entered correctly in your gradle.properties file
Here is how you do it: (change the ip and ports to that of your proxy server
#systemProp.https.nonProxyHosts=localhost
#systemProp.httpp.nonProxyHosts=localhost
#systemProp.https.proxyPort=8080
#systemProp.http.proxyHost=10.11.12.13
#systemProp.https.proxyHost=10.11.12.13
#systemProp.http.proxyPort=8080

Related

Gradle sync failed: Could not connect to server

In my android studio 3.0 i am continuously getting this error -
Cannot start internal HTTP server. Git integration, JavaScript debugger and LiveEdit may operate with errors. Please check your firewall settings and restart Android Studio.
after this my gradle sync also failed stating the error -
Gradle sync failed: Could not connect to server [a3ea2c7d-cc16-4af2-82a9-037277903c02 port:49555, addresses:[/127.0.0.1]]. Tried addresses: [/127.0.0.1].
One thing to note down that this gradle sync failed when it(gradle) is connecting to gradle daemon.
i have tried all the options from stack overflow like netsh winsock reset etc.
But nothing work for me.
Also to mention i do not use embedded JDK in AS. I have provided it my downloaded jdk8.
How to solve this problem.
Thanks in advance.
Make sure your machine is connected to the internet.
Check the link here: Configure Android Studio - Proxy
I personally recommend that you try disabling the proxy if it is enabled.
Go to Windows Firewall -> Inbound & Outbound Rules -> add java.exe from JDK path & studio.exe from Android Studio directory.

What is gradle sync in Android Studio?

What is it? And what does it do?
I'm working on an enterprise that has a proxy, and it fails trying to connect to somewhere.
Why does it needs internet connection? What ports does it use?
EDIT: The answer of the user Caleb was perfect. I would like to add that the proxy should be configured too in the gradle.properties. Something like this:
systemProp.http.proxyHost=*proxyAddress*
systemProp.http.proxyPort=*portNumber*
systemProp.https.proxyHost=*proxyAddress*
systemProp.https.proxyPort=*portNumber*
What is it? And what does it do?
Gradle sync is a gradle task that looks through all of your dependencies listed in your build.gradle files and tries to download the specified version.
dependencies {
compile '...your dependency...'
}
Why does it needs internet connection? What ports does it use?
It requires an internet connection because it is usually downloading these dependencies from a remote location. You can define what ports it uses by changing your gradle.properties. (see below)
I'm working on an enterprise that has a proxy, and it fails trying to
connect to somewhere.
Your work proxy may be blocking this and you'll need to add your proxy configuration to solve your issues.
Go into:
File-->Settings--> Android Studio Preferences --> Appearance & Behavior / System Settings/ HTTP Proxy
and update your proxy configuration url to your work proxy. (automatic or manual depending on your setup).
NOTE: If you are using the command line to run your gradle build, you will probably need to update the proxy settings via your gradle.properties file.
Global Properties File Location : ~/.gradle/gradle.properties
(or use your local project file if you have one)
Add proxy settings to this file:
HTTPS
systemProp.https.proxyHost=<proxy host>
systemProp.https.proxyPort=<your proxy port>
systemProp.https.nonProxyHosts=<your non-proxy host>
systemProp.https.proxyPassword=<your pw>
HTTP
systemProp.http.proxyHost=<proxy host>
systemProp.http.proxyPort=<your proxy port>
systemProp.http.nonProxyHosts=<your non-proxy host>
systemProp.http.proxyPassword=<your pw>
If you absolutely cannot get an internet connection via gradle you'll need to download the dependencies another way and reference them locally on your computer or local network.
(See this guide for using local jars)
What is it?
I believe it's an IntelliJ/Android Studio term for these Gradle tasks:
dependencies
build
Gradle itself doesn't have "sync" task.
I use the term "believe" since there's no explanation from Gradle/IntelliJ/Android Studio official documentation 😂
And what does it do?
Sync is a phase where the IDE preparing everything, including downloading your dependencies.
When the sync is finished, the user can start coding.
When the sync fails, the IDE is not working properly. The user need to spend time to fix the configuration first.
After Gradle finished syncing, the IDE start another task, like indexing.
Gradle: Build...
Gradle: Configure projects...
Indexing...
I'm working on an enterprise that has a proxy, and it fails trying to connect to somewhere. Why does it needs internet connection? What ports does it use?
Answered above.
Bonus: How to speed up sync
Before opening the project using Android Studio/IntelliJ, open the project using terminal and run the gradle tasks.
cd myproject
./gradlew app:dependencies module:dependencies
./gradlew build
After that, open the project. The sync should be much faster now (since you've downloaded the dependencies in terminal).
It needs internet connection to download dependencies

Gradle sync failed: connection time out: consult IDE log for more details

I just installed Android studio 2.3.1, but after starting it is telling me "Grade sync failed: connection time out: connect consult IDE log for more details". Pls I don't know what to do.
Caused by: java.util.zip.ZipException: error in opening zip file
This mean that a file that Gradle has downloaded has become corrupted due to somehow or some reason. This might be the download of Gradle itself (which the wrapper does) or any dependency that Gradle has downloaded to run your build.
Gradle doesn't attempt to detect or resolve the problem, so you need to fix it manually. The solution is often to purge Gradle's download caches and let it get fresh copies of what it needs.
To do that, delete the .gradle directories in both your home directory and in your project's root directory and try building again.
In window home directory of gradle is
C:\Users\User.gradle
In Mac OSX home directory
/Users/User_name/.gradle
If you still haven't figured out this problem yet, it's because you literally have no internet connection which is mandatory for gradle building since the platform checks for potential updates for say, sdk versions, from a server.
However, if you want to build and do your work offline, then go to File -> Settings -> Build, Execution, Deployment -> Gradle -> Check Offline work under Global Gradle settings
With reference to #DaveNOTDavid's answer, i tried this: Go to File->Settings->Build,Execution,Deployment->Gradle-> and select "Use default gradle wrapper(recommended)". Then sync your project, everything will work fine. But you need an internet connection.
I was facing the same issue while downloading the gradle zip from https://services.gradle.org/distributions/gradle-4.1-all.zip. My issue related to proxy settings, I disabled the proxy & click on Try Again button in build.gradle file.
In my case i activated antivirus it blocks the downloading gradle files turn of your firewall settings
Click on the SDK Manager and click SDK Tools and check if NDK and CMAKE are checked or not. If they are not checked download and install them. And if the problem persists just try it with a stable internet connection with a fast or a moderate speed. It had happened with me also when I was doing it with mobile phone internet then I tried it with a broadband with fast internet.
Basically it's a network issue. if you are working using wifi use vpn that would solve the problem
connection timed out:
solution: Just disable your anti-virus for an hour and restart the android studios, in my case my antivirus blocked the connection. while restarting the android studios firewall will ask you the permission, allow it and its all done. The gradle will build successfully
These situations generally occur due to the problem in downloading Gradle components, to overcome this, check your internet proxy and connection properly.
Just try to use some other source internet connection instead of the one you were using while having this error. Like I faced the same problem and I disconnected my system from the wifi and connected it to my personal mobile hotspot. then go to file->Invalidate Caches/ Restart...
and your Gradle will build successfully this time.

gradle unable to establish connection behind proxy

I am trying to run the react native examples for androind on windows. My system is setup behind a corporate proxy. i am unable to get gradle to work though.
Following proxy settings are defined in the global gradle.properties.
systemProp.http.proxyHost=<proxy.url>
systemProp.http.proxyPort=8080
systemProp.https.proxyHost=<proxy.url>
systemProp.https.proxyPort=8080
I tried running the build from android studio(2.0), same story. My network proxy is properly configured there, i checked, i can access the internet from it.
i changed my build tools to point to the gradle distribution that comes with it, that didn't change anything either.
i keep getting an error saying
"Unknown host <my.proxy.url>. You may need to adjust the proxy settings in gradle"
I also checked, i can download the poms it requires from my browser. it seems as if gradle is unable to work from behind a proxy, at all.
can anyone help?

Android studio "Cannot start internal HTTP server"

I'am trying to install Android studio, but bad luck..:-(.
Windows 7
Latest Andriod studio
Latest Java
Installed the latest Java and also added it to the system settings according to http://www.youtube.com/watch?v=TTrUX1kUpDo
Also downloaded Gradle and updated the system settings
Stopped all firewall actions
So far so good, Android studio is also starting without any problems. But then I get two messages:
Internal HTTP server disabled: Cannot start internal HTTP server. Git integration, JavaScript debugger and LiveEdit may operate with errors. Please check your firewall settings and restart Android Studio
Gradle 'Nieuwproject' project refresh failed: Connection refused: connect
So after a few days of trying I was hoping that somebody could help me out..:-)
Here's what worked for me - I got the same error:
Internal HTTP server disabled: Cannot start internal HTTP server. Git integration, JavaScript debugger and LiveEdit may operate with errors. Please check your firewall settings and restart Android Studio
Run command prompt as administrator - type cmd in the 'search programs and files' text box in the Windows Start menu; right-click and select 'Run as administrator'.
At the command prompt, type
netsh winsock reset
Restart your PC
This worked for me.
Just to mention: I also added Android Studio and Gradle folders to my virus protection exceptions in case it was being blocked, but that didn't resolve the problem; the problem was only resolved once I followed the steps above.
Turn OFF firewall then turn ON again.
Sometimes firewall blocks it automatically when you start your PC. It also blocks to internet browsing for other reason but restarting firewall may solve this problem.
I encountered this problem after uninstalling Avast from my Computer,few days later i installed Avast again and the problem went away,Dont know what the connection is but thats what solved my problem
if Shell&ServicesEngine is installed on your computer, uninstall it and restart the Android Studio.

Categories

Resources