我在Android Studio中运行应用时遇到问题。当我按下Run时,"选择部署目标"发生对话框弹出,但我永远无法看到任何模拟器或设备发生。事件日志打印出以下内容并无限期重复:
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
我可以使用命令行运行react-native项目,但直接使用Android Studio时会发生这种情况。
我尝试在Android Studio中创建新项目,但结果仍然相同。我相信一旦我从Android Studio 3.0更新到3.1,就会发生这种情况。
有任何想法可以解决此问题或获取更多信息吗?
感谢。
系统信息:
MacOS High Sierra 10.3.14 Macbook Pro(2011年末)
软件信息:
Android Studio 3.1.2 Java 9.0.4
答案 0 :(得分:2)
我在Mac上也遇到了类似的问题,并通过将行 127.0.0.1 localhost 附加到/ etc / hosts
来解决答案 1 :(得分:1)
我在Mac上也遇到了类似的问题,并通过删除该行来修复了该问题 / strong / etc / hosts中的 :: 1本地主机。