0

I am trying to start android emulator in vs code but it gives me the following errors:

Exception in thread "main" java.net.UnknownHostException: services.gradle.org
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:184)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:589)
    at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:666)
    at sun.security.ssl.BaseSSLSocketImpl.connect(BaseSSLSocketImpl.java:173)
    at sun.net.NetworkClient.doConnect(NetworkClient.java:180)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:463)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:558)
    at sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:264)
    at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:367)
    at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:191)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1156)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1050)
    at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:177)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1564)
    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)
Gradle task assembleDebug failed with exit code 1

When I run flutter doctor, there is no any issues

I try to wipe data from android studio AVD manager and now it gives me an error saying:

Failed to launch flutter emulator: Error: Emulator didn't connect within 60 seconds

I follow the steps from this link and now it stuck at Running Gradle task 'assembleDebug'... when I try to run debug in vs code.

Ayman Tarig
  • 23
  • 2
  • 6
  • i think you will get you answer here: [link](https://stackoverflow.com/questions/55677874/flutter-failing-to-connect-to-emulator-with-vscode) – Ara Hussein Apr 20 '20 at 06:35
  • @AraHussein I follow the steps and now it stuck at ```Running Gradle task 'assembleDebug'...``` – Ayman Tarig Apr 20 '20 at 07:58

1 Answers1

0

One of the workaround for the error

Emulator didn't connect within 60 seconds

Is to force kill the process:

  1. Go to cmd and type adb kill-server
  2. Go to task manager and find adb in processes. If you find one, right click on it and click on end process tree.

Then you can go ahead of wiping the data in your emulator as suggested in this SO post.

In your case that it is stuck at

Running Gradle task 'assembleDebug'...

Try to follow these steps:

  1. Open your Flutter Project directory.
  2. Change directory to android directory in your Flutter project directory cd android
  3. clean gradle ./gradlew clean
  4. Build gradle ./gradlew build or you can combine both commands with just ./gradlew clean build
  5. Now run your flutter project. If you use vscode, press F5. First time gradle running assembleDebug will take time.

PS: Delete gradle in case of all that steps don't work

MαπμQμαπkγVπ.0
  • 5,887
  • 1
  • 27
  • 65