【问题标题】:Cannot connect emulator in Android Studio on MacOS无法在 MacOS 上的 Android Studio 中连接模拟器
【发布时间】:2021-12-29 04:32:12
【问题描述】:

我的模拟器有问题,我无法在上面运行我的应用程序。几个月前,我仍然可以打开我的旧项目并在模拟器上运行它们。几个月后,我带着一个新项目回来了,现在我可以打开模拟器,但它与我的项目没有连接(也与我的旧项目)。

我看到当我打开模拟器时出现错误提示 faild to start adb 并且另一个通知显示 daemon is terminated。我在谷歌上搜索这些以找到解决方案,但没有任何帮助。

这是我的flutter doctor -v

or found issues in 3 categories.
Macbooks-MacBook-Pro-3:learning_bee quanan$ flutter doctor -v
[✓] Flutter (Channel dev, 2.3.0-24.0.pre, on Mac OS X 10.14.6 18G2022 darwin-x64, locale en-US)
    • Flutter version 2.3.0-24.0.pre at /Users/quanan/Downloads/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 2b9537c783 (5 months ago), 2021-06-11 22:11:53 -0700
    • Engine revision ddbac024d1
    • Dart version 2.14.0 (build 2.14.0-188.0.dev)

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/quanan/Library/Android/sdk
    • Platform android-30, build-tools 31.0.0
    • Java binary at: /Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Home/bin/java
    • Java version Java(TM) SE Runtime Environment (build 1.8.0_271-b09)
    • All Android licenses accepted.

[!] Xcode - develop for iOS and macOS
    ✗ Xcode installation is incomplete; a full installation is necessary for iOS development.
      Download at: https://developer.apple.com/xcode/download/
      Or install Xcode via the App Store.
      Once installed, run:
        sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
        sudo xcodebuild -runFirstLaunch
    ! CocoaPods 1.9.3 out of date (1.10.0 is recommended).
        CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the Dart side.
        Without CocoaPods, plugins will not work on iOS or macOS.
        For more info, see https://flutter.dev/platform-plugins
      To upgrade see https://guides.cocoapods.org/using/getting-started.html#installation for instructions.

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[!] Android Studio (version 2020.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      ???? https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      ???? https://plugins.jetbrains.com/plugin/6351-dart
    ✗ Unable to find bundled Java version.
    • Try updating or re-installing Android Studio.

[✓] VS Code (version 1.62.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension can be installed from:
      ???? https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[☠] Connected device (the doctor check crashed)
    ✗ Due to an error, the doctor check did not complete. If the error message below is not helpful, please let us know about this issue at
      https://github.com/flutter/flutter/issues.
    ✗ Exception: Unable to run "adb", check your Android SDK installation and ANDROID_SDK_ROOT environment variable:
      /Users/quanan/Library/Android/sdk/platform-tools/adb
    • #0      throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
      #1      AndroidDevices.pollingGetDevices (package:flutter_tools/src/android/android_device_discovery.dart:78:7)
      <asynchronous suspension>
      #2      PollingDeviceDiscovery._populateDevices (package:flutter_tools/src/device.dart:397:54)
      <asynchronous suspension>
      #3      Future.wait.<anonymous closure> (dart:async/future.dart)
      <asynchronous suspension>
      #4      DeviceManager.getAllConnectedDevices (package:flutter_tools/src/device.dart:163:40)
      <asynchronous suspension>
      #5      DeviceValidator.validate (package:flutter_tools/src/doctor.dart:515:34)
      <asynchronous suspension>
      #6      asyncGuard.<anonymous closure> (package:flutter_tools/src/base/async_guard.dart:111:24)
      <asynchronous suspension>


! Doctor found issues in 3 categories.

由于我的 SSD 只有 125GB 左右,一年前我不得不删除 Xcode 和所有 ios 模拟器,因此出现错误的 Xcode 部分很好。 如果我没记错的话,我的应用程序在模拟器上仍然可以正常运行,我仍然会看到Flutter daemon terminated 的错误消息,但它仍然可以正常运行,所以我认为这不会是错误。当我打开 android studio 时发生此错误

这是我启动 android 模拟器时的错误显示:

【问题讨论】:

  • '找不到捆绑的 Java 版本'。也许,你应该看看这里。
  • 我点击了链接,它解决了 '无法找到捆绑的 Java 版本',但它仍然无法在模拟器上运行我的应用程序

标签: flutter android-studio adb daemon


【解决方案1】:

我解决了问题

  1. 无法启动模拟器(模拟器进程已终止)
  2. adb 没有确认
  3. Flutter 守护进程已终止

使用这些步骤(感谢this post):

  1. 重新安装所有 Android Studio(之后,我仍然得到 adb + daemon 错误)
  2. 重新启动我的 Macbook 以确保没有 adb 实例正在运行(之后我打开 Android Studio 并没有看到守护进程 + adb 错误,但在启动名为“Dyld 错误消息”的模拟器时出现新错误)
  3. 关闭 Android Studio
  4. 下载并解压此older version emulator
  5. 打开终端并运行open ~/Library/Android/sdk,这应该会打开一个文件夹,然后将模拟器文件夹替换为我刚刚解压缩的文件夹
  6. 正常运行android studio

操作系统:MacOS Mojave,IMO 发生此错误是因为较新的模拟器不支持旧的 MacOS 版本。您可以升级您的 MacOS 或 DOWNGRADE 模拟器版本

【讨论】:

    猜你喜欢
    • 2016-08-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-21
    • 2015-02-19
    • 1970-01-01
    • 1970-01-01
    • 2017-03-12
    相关资源
    最近更新 更多