Reputation: 83
I have a problem running apps in Android Studio. When I press Run, the "Select Deployment Target" dialog popup occurs, but I am never able to see any emulators or devices occur. The event log prints out the following and repeats indefinitely:
5/6/18
12:40 PM Gradle sync started
12:40 PM Project setup started
12:41 PM Gradle sync finished in 49s 932ms
12:41 PM Executing tasks: [:app:generateDebugSources]
12:41 PM Gradle build finished in 15s 765ms
12:44 PM Unable to open connection to: localhost/0.0.0.0:5037, due to: java.net.ConnectException: Connection refused
12:44 PM Connection attempts: 1
12:44 PM Unable to open connection to: localhost/0.0.0.0:5037, due to: java.net.ConnectException: Connection refused
12:44 PM Connection attempts: 2
12:44 PM Unable to open connection to: localhost/0.0.0.0:5037, due to: java.net.ConnectException: Connection refused
12:44 PM Connection attempts: 3
12:44 PM Unable to open connection to: localhost/0.0.0.0:5037, due to: java.net.ConnectException: Connection refused
12:44 PM Connection attempts: 4
12:44 PM Unable to open connection to: localhost/0.0.0.0:5037, due to: java.net.ConnectException: Connection refused
12:44 PM Connection attempts: 5
I am able to run react-native projects using the command line, but when using Android Studio directly, this occurs.
I have tried creating new projects in Android Studio and still have the same results. I believe this started to happen once I updated from Android Studio 3.0 to 3.1.
Any ideas to fix this issue or get more information?
Thanks.
System Information:
MacOS High Sierra 10.3.14 Macbook Pro (Late 2011)
Software Information:
Android Studio 3.1.2 Java 9.0.4
Upvotes: 4
Views: 3308
Reputation: 1978
I had the same problem. I resolved it using 10.0.2.2 instead of 0.0.0.0 for default AVD. I will hit 0.0.0.0 and work. Add the port with it as you desire. Add it in network-security-config too for cleartextTrafficPermitted.
10.0.2.2 is a Special alias to your host loopback interface (127.0.0.1 on your development machine)
If you are Genymotion emulator - use 10.0.3.2.
Upvotes: 0
Reputation: 760
I also had a similar issue on Mac and fixed it by appending the line 127.0.0.1 localhost to /etc/hosts
Upvotes: 4
Reputation: 21
I also had a similar issue on Mac and fixed it by removing the line ::1 localhost from /private/etc/hosts.
Upvotes: 2
Reputation: 1920
I had the same issue, i fixed it by removing 0.0.0.0
mapping in /etc/hosts
.
Earlier i had a mapping 0.0.0.0 localhost
in /etc/hosts
file.
Upvotes: 8