Flutter Lost connection to device

6,221

Solution 1

If you updated the android SDK, the licenses may have changed. Depending on how you did the update you may or may not have been prompted to accept the changes, or maybe it just doesn't save the fact that you did accept them in a way flutter can understand.

To resolve, try running

flutter doctor --android-licenses

This should prompt you to accept licenses.

Solution 2

When I tried to run the app from the XCode, it showed me the actual error. I was missing the google Ad Identifier inside the Info.plist file. Once I added it, it started working fine.

Thanks for your time and help.

Share:
6,221
Phuoc
Author by

Phuoc

Updated on December 07, 2022

Comments

  • Phuoc
    Phuoc 6 months

    I use Iphone 11 emulator. I hit run button and got this:

    Launching lib/main.dart on iPhone 11 in debug mode...
    Running pod install...
    Running Xcode build...
    Xcode build done.                                           37.0s
    Waiting for iPhone 11 to report its views...
    Debug service listening on ws://127.0.0.1:65405/L1H3N-Q0JFU=/ws
    Syncing files to device iPhone 11...
    Lost connection to device.
    

    It opens the app and shut down immediately. I performed flutter clean but it's not working. This is my flutter doctor":

    [✓] Flutter (Channel master, 1.24.0-2.0.pre.98, on Mac OS X 10.15.4 19E287 darwin-x64, locale en-GB)
    [!] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
        ✗ Android license status unknown.
          Run `flutter doctor --android-licenses` to accept the SDK licenses.
          See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.
    [✓] Xcode - develop for iOS and macOS (Xcode 11.3.1)
    [✓] Android Studio (version 4.0)
    [✓] VS Code (version 1.49.3)
    [✓] Connected device (1 available)
    
  • yardstick17 about 2 years
    I am facing the same issue. The issue exists on both - iOS and Android.
  • Tananga
    Tananga about 2 years
    Thank you. Your comment helped me to solve my problem. In my case I needed to add apiKey parameter in FirebaseOptions and only xCode show the error