Test Project
Test Project

Reputation: 41

How to solve gradle error in flutter with android studio?

I Installed android studio with all requirements for flutter, when I run flutter doctor everything is fine and installed correctly. I created a normal android project and it's running fine with no errors. Now after I created new flutter project I get this error whenever I run the project. I couldn't solve it.

Launching lib\main.dart on Android SDK built for x86 in debug mode... Initializing gradle... Finished with error: ProcessException: Process "C:\Users\Nesma\AndroidStudioProjects\flutter_app\flutter_apptest\android\gradlew.bat" exited abnormally: Downloading https://services.gradle.org/distributions/gradle-4.10.2-all.zip

Exception in thread "main" java.io.IOException: Unable to tunnel through proxy. Proxy returns "HTTP/1.1 503 Too many open connections"
    at sun.net.www.protocol.http.HttpURLConnection.doTunneling(HttpURLConnection.java:2142)
    at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:183)
    at sun.net.www.protocol.http.HttpURLConnection.followRedirect0(HttpURLConnection.java:2729)
    at sun.net.www.protocol.http.HttpURLConnection.followRedirect(HttpURLConnection.java:2641)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1824)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1492)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:263)
    at org.gradle.wrapper.Download.downloadInternal(Download.java:58)
    at org.gradle.wrapper.Download.download(Download.java:44)
    at org.gradle.wrapper.Install$1.call(Install.java:61)
    at org.gradle.wrapper.Install$1.call(Install.java:48)
    at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:65)
    at org.gradle.wrapper.Install.createDist(Install.java:48)
    at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:128)
    at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
  Command: C:\Users\Nesma\AndroidStudioProjects\flutter_app\flutter_apptest\android\gradlew.bat -v

Upvotes: 4

Views: 5008

Answers (2)

Kas Elvirov
Kas Elvirov

Reputation: 7980

I solved this problem by doing two things:

  • downgrading (but maybe you have to upgrade) value for gradle. Go to android\gradle\wrapper\gradle-wrapper.properties and change value for distributionUrl. In my case - from 5.6.2 to 5.4.1
  • setting up proxy settings (because I have corporate firewall). Go to android\gradle.properties and add something like this. If you need to add user, google it
    systemProp.http.proxyHost=somehost
    systemProp.http.proxyPort=port
    systemProp.https.proxyHost=somehost
    systemProp.https.proxyPort=port

Upvotes: 1

Wilmer
Wilmer

Reputation: 512

The problem is because you don't have the gradle-4.10.2-all version and when you run it is trying to download it without success.

If you already created another project with gradle, you can check the versions you have in: C:\Users\{USERNAME}\.gradle\wrapper\dists\ and modify the gradle configuration of your new project.

Upvotes: 1

Related Questions