Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better handle x86 / x86_64 issues from launching Android emulators #15055

Closed
geekrumper opened this issue Mar 2, 2018 · 25 comments
Closed

Better handle x86 / x86_64 issues from launching Android emulators #15055

geekrumper opened this issue Mar 2, 2018 · 25 comments
Labels
platform-android Android applications specifically

Comments

@geekrumper
Copy link

geekrumper commented Mar 2, 2018

Steps to Reproduce

  • start project in IntelliJ
  • choose emulator in "Device Selector"
  • error message appears (bottom right)

Alternative approach

  • open Android Device Manager
  • start emulator
  • Android Monitor recognizes emulator and attaches itself
  • "Device Selector" does not seem to update on previous event
  • run app
  • error message "No Connected Devices Found" (allthough Android Monitor is attached)

Screenshots

flutter_error

flutter_2

comments

  • as you can see, "flutter doctor" has no issues
  • Android Monitor is attached
  • AVD Manager can start emulator, but "Device Selctor" not (PANIC message)
  • This happens every time I update Android plugins for IntelliJ

Logs

Run your application with flutter run and attach all the log output.

Run flutter analyze and attach any output of that command also.

λ flutter analyze
Running "flutter packages get" in fludder...
Analyzing D:\WORKSPACE\DART\fludder...
  error - The constructor returns type 'dynamic' that isn't of expected type 'Widget' at test\widget_test.dart:15:29 - strong_mode_invalid_cast_new_expr
  error - Undefined class 'MyApp' at test\widget_test.dart:15:33 - undefined_class
  hint - Unused import at test\widget_test.dart:10:8 - unused_import
3 issues found.
(Ran in 8.0s)

Flutter Doctor

D:\
λ flutter doctor -v
[  +18 ms] [D:\flutter\] git rev-parse --abbrev-ref --symbolic @{u}
[ +131 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
[        ] origin/alpha
[        ] [D:\flutter\] git rev-parse --abbrev-ref HEAD
[  +87 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[        ] alpha
[        ] [D:\flutter\] git ls-remote --get-url origin
[  +88 ms] Exit code 0 from: git ls-remote --get-url origin
[        ] https://github.com/flutter/flutter.git
[        ] [D:\flutter\] git log -n 1 --pretty=format:%H
[  +88 ms] Exit code 0 from: git log -n 1 --pretty=format:%H
[        ] 553fc4264e5c3bd85531e73fb7d89bdfab0fa3ec
[        ] [D:\flutter\] git log -n 1 --pretty=format:%ar
[  +74 ms] Exit code 0 from: git log -n 1 --pretty=format:%ar
[        ] 15 hours ago
[   +1 ms] [D:\flutter\] git describe --match v*.*.* --first-parent --long --tags
[ +173 ms] Exit code 0 from: git describe --match v*.*.* --first-parent --long --tags
[        ] v0.0.21-1-g553fc4264
[ +783 ms] [√] Flutter (on Microsoft Windows [Version 10.0.16299.248], locale de-CH, channel alpha)
[        ]     • Flutter version 0.0.22-pre.1 at D:\flutter
[        ]     • Framework revision 553fc4264e (15 hours ago), 2018-03-01 09:30:25 -0800
[        ]     • Engine revision 6921873c71
[        ]     • Tools Dart version 2.0.0-dev.16.0
[        ]     • Engine Dart version 2.0.0-edge.da1f52592ef73fe3afa485385cb995b9aec0181a
[ +123 ms] java -version
[  +95 ms] [√] Android toolchain - develop for Android devices (Android SDK 27.0.3)
[        ]     • Android SDK at C:\Users\ecoissy\AppData\Local\Android\sdk
[        ]     • Android NDK location not configured (optional; useful for native profiling support)
[        ]     • Platform android-27, build-tools 27.0.3
[        ]     • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
[        ]     • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-915-b01)
[   +1 ms] [√] Android Studio (version 3.0)
[        ]     • Android Studio at C:\Program Files\Android\Android Studio
[        ]     • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-915-b01)
[ +103 ms] [√] IntelliJ IDEA Ultimate Edition (version 2017.3)
[        ]     • Flutter plugin version 22.2.2
[        ]     • Dart plugin version 173.4548.30
[   +7 ms] C:\Users\ecoissy\AppData\Local\Android\sdk\platform-tools\adb devices -l
[+4181 ms] Exit code 0 from: C:\Users\ecoissy\AppData\Local\Android\sdk\platform-tools\adb devices -l
[        ] List of devices attached
[  +21 ms] C:\Users\ecoissy\AppData\Local\Android\sdk\platform-tools\adb devices -l
[ +118 ms] List of devices attached
[        ] [-] Connected devices
[        ]     • None
[  +16 ms] "flutter doctor" took 5’291ms.
[ +258 ms] ensureAnalyticsSent: 254ms
[   +5 ms] exiting with code 0

For more information about diagnosing and reporting Flutter bugs, please see https://flutter.io/bug-reports/.

@zoechi
Copy link
Contributor

zoechi commented Mar 2, 2018

Looks like you are using an old Flutter version.
This version frequently caused issues with flutter upgrade not updating.
The latest version is Flutter 0.1.7

@geekrumper
Copy link
Author

@zoechi
Oh, does that mean I have to manually install flutter then? I did flutter upgrade before experiencing this issue.

@zoechi
Copy link
Contributor

zoechi commented Mar 2, 2018

I always suggested to just purge the flutter install and reinstall.
There are other ways with git reset --hard and probably additional commands, but I never dove into that path. Reinstall is simpler to explain by just pointing at the install instructions web page ;-)

@geekrumper
Copy link
Author

I've deleted my local repo and did a fresh checkout.

It works now... but only with following approach:

  • use AVD Manager to start device
  • run flutter doctor to verify if flutter picks up emulator
  • run flutter run

Device Selector in IntelliJ still brings PANIC error message. And running project from IntelliJ still yields "No Connected Devices Found", allthough I have an emulator running.

λ flutter --version Flutter 0.1.5 • channel beta • https://github.com/flutter/flutter.git Framework • revision 3ea4d06340 (8 days ago) • 2018-02-22 11:12:39 -0800 Engine • revision ead227f118 Tools • Dart 2.0.0-dev.28.0.flutter-0b4f01f759

I have Flutter 0.1.5 now.

@zoechi
Copy link
Contributor

zoechi commented Mar 2, 2018

Have you tried restarting IntelliJ (just to be sure)?

@geekrumper
Copy link
Author

Yes, I've done many things after a fresh checkout

  • invalidate caches and restart
  • deleted old emulator
  • added new one in AVD Manager
  • re-assigned Android SDK

All of this did not help avoiding PANIC error message.

@zoechi
Copy link
Contributor

zoechi commented Mar 2, 2018

I'm out of ideas. Can you please add the exact error message. I haven't found it above.

@zoechi
Copy link
Contributor

zoechi commented Mar 2, 2018

D:\ is not a network drive by any chance?

@geekrumper
Copy link
Author

D:\ is a local drive.
The exact error message is in the first screenshot (bottom right).

@Hixie
Copy link
Contributor

Hixie commented Mar 3, 2018

cc @devoncarew

@devoncarew
Copy link
Member

@geekrumper, it looks like the Android Monitor tool from the Android plugins is having trouble executing your emulator image. I would try creating a new one (and you may want to delete the old one as well). I don't believe this is an issue with the flutter intellij tooling per se, but more a local configuration issue, so am closing. Thanks for the report!

@glesica
Copy link

glesica commented Mar 10, 2018

I'm seeing the same error in Android Studio. I can manually start the AVD from the AVD Manager, but when I select it in the toolbar ("Flutter Device Selection") I see the error described above. I have deleted the device and recreated it.

@timekarma
Copy link

I am getting the same error.
I did a clean install of flutter on windows 10.
New Install of Android studio.
I can open the device emulator in Android, but not in Flutter, gives error
"Error Opening Emulator: PANIC: Missing emulator engine program for 'x86' CPU."

@cyanfr
Copy link

cyanfr commented Mar 12, 2018

This is how I resolved this on Windows 10 where I was getting the same error.
Installed components:
flutter 1.5 (beta)
Android Studio 3.0.1 (64 bit)
IntelliJ Ultimate 2017.3.4
Java JDK 1.8.0_61 (64 bit only)
Envirs:
%ANDROID_HOME%
C:\Users<user>\AppData\Local\Android\Sdk

%ANDROID_SDK_ROOT%
C:\Users<user>\AppData\Local\Android\Sdk

%path% includes these in this order:
C:\Users\\AppData\Local\Android\Sdk\emulator
C:\Users\\AppData\Local\Android\Sdk\emulator\bin
C:\Users\\AppData\Local\Android\Sdk\platform-tools
C:\Users\\AppData\Local\Android\Sdk\tools
C:\Users\\AppData\Local\Android\Sdk\tools\bin
C:\Users\\AppData\Local\flutter\bin
C:\Users\\AppData\Local\dart-sdk

I guessed that since I was all x64 for all components that IntelliJ might be having a problem with the fact that the out-of-box configured virtual devices over in Android Studio are x86 and not x86_64.

My solution was to:

  • open Android Studio
  • open AVD Manager form Tools > Android
  • edit the config for the existing x86 based devices to instead us an API of type x86_64.
  • save and exit all the way out.
  • open IntelliJ and now those devices set x86_64 types work.

AVD 1
AVD 2
AVD 3
AVD 4
AVD 5

@geekrumper
Copy link
Author

geekrumper commented Mar 13, 2018

@devoncarew please refer to one of my previous comments:

Yes, I've done many things after a fresh checkout

  • invalidate caches and restart
  • deleted old emulator
  • added new one in AVD Manager
  • re-assigned Android SDK
    All of this did not help avoiding PANIC error message.

Deleting and creating a new emulator does not solve the problem. And therefore, this issue should be re-opened.

In fact I even get this message on a fresh installed machine (OS, IDEA, Android Studio, Sdk, flutter)...

@geekrumper
Copy link
Author

geekrumper commented Mar 13, 2018

@cyanfr
great input there. I was able to start an emulator (x86_64) through the "Device Selector" without any problems. Still, IntelliJ does not seem to pick it up, which means I cannot use the Run-Command (Shift-F10) from IntelliJ.

This leads to an alternative work process

  • by having flutter be ran in a terminal
  • making source code changes in an editor
  • focussing back to terminal and hitting 'r' for hot reload

@devoncarew
Why should this be an image problem, if the AVD Manager can start the image without any issues?

flutter_panic

@abarrafo
Copy link

abarrafo commented Mar 17, 2018

I was seeing this same problem when trying to run this with a Nexus 5x API 27 X86 configuration. I created a new Virtual device from intellij, tools > Android > AVD Manager. Pixel XL API 27, and I no longer get this error on the new virtual device.

screenshot from 2018-03-17 10-46-49

peek 2018-03-17 11-00

UPDATE:
Turns out, after I had run ln -s emulator64-x86 emulator-x86_64 in Android/SDK/tools. All new Virtual Devices work. I just had to remove the virtial device mentioned above as it was created prior to running this command.

I am on Ubuntu 17.10

@geekrumper
Copy link
Author

geekrumper commented Mar 18, 2018

Hey guys,
I appreciate the community effort and was able to gather a couple of useful information:

  • make sure the pre-defined emulator is removed (deleted), this one will mostly cause the errors
  • use the appropriate system type for the emulator, e.g. "x86_64" if you are using 64-bit OS with IntelliJ
  • give your new emulator an easy name, since you'll be starting it from the terminal (e.g. "nexus")
  • launch the emulator in a terminal with the "emulator" command in Android tools
    %ANDROID_HOME%\tools\emulator -avd %EMULATOR_NAME%
  • after starting the emulator, make sure the "Device Selector" has picked up the running emulator
  • Shift-F10 to run or Shift-F9 to debug
  • have fun!!!

flutter_workflow

@devoncarew devoncarew changed the title PANIC: Missing emulator engine program for 'x86' CPU Better handle x86 / x86_64 issues from launching Android emulators Mar 19, 2018
@devoncarew
Copy link
Member

@geekrumper (and @abarrafo and @cyanfr), thanks much for the analysis and summary! Very useful, and likely an issue that many people are hitting.

I only see one copy of emulator in my android sdk tools directory (I'm on a mac). From the notes above it looks like at least windows has linux has two variants (emulator64-x86, emulator-x86_64), and perhaps windows as well.

@devoncarew devoncarew reopened this Mar 19, 2018
@cyanfr
Copy link

cyanfr commented Mar 20, 2018

@devoncarew A couple more things I found that seemed to help. Details in case anyone else stumbles on this thread and they might help.

  1. Revised what I had above and added just following global envir vars...

Added to Path:
C:\Users\my_user\AppData\Local\flutter\bin
C:\Users\my_user\AppData\Local\Android\Sdk\platform-tools
C:\Users\my_user\AppData\Local\Android\Sdk\tools
C:\Users\my_user\AppData\Local\Android\Sdk\tools\bin

New Envir Vars:
ANDROID_AVD_HOME: C:\Users\my_user.android\avd
ANDROID_EMULATOR_HOME: C:\Users\my_user.android
ANDROID_SDK_ROOT: C:\Users\my_user\AppData\Local\Android\Sdk

  1. This next bit seemed to make more of a difference
    .
    I noticed that the global vars did not seem to get picked up by IntelliJ.
    So in the generic settings of IntelliJ I added the following three vars same as in my system's envir.
    generic settings 1
    generic settings 2

Then in the specific project structure settings, I set the JDK SDK loc and the Android SDK loc as these did not seem to get picked up any other way. Like so...
project specific settings 1
project specific settings 2

After this, at least on my Windows 10 box with only 64 bit apps, the AVD images started to work.
That's the fresh ones as @geekrumper says, and not the default ones.

Although I did get the settings for my new pixel 2 xl image from the ones in Android Studio.

Interestingly after I made these changes I could open both x86_64 AND x86 bit AVD images.
Now this is never from that little dropdown. This is by starting the AVD Manager and starting the image from there.

So not from here (it always produced error):
image start 1

But from here, I would pick an image and start it:
image start 1

And then once the image was started, it interacted just fine with IntelliJ.

Then in the project structure specific settings I checked and added the following.
JDK path and the Android SDK path. First JDK then Android SDK.

@SpicyCactuar
Copy link

For what it's worth, i had the same issue in Ubuntu 18.04 and it was solved by doing what @cyanfr mentioned.

Can provide more information if it's necessary.

@eseidelGoogle eseidelGoogle added the platform-android Android applications specifically label Jun 18, 2018
@eseidelGoogle
Copy link
Contributor

FYI @DanTup who recently added flutter emulators command and might have interest in this.

@DanTup
Copy link
Contributor

DanTup commented Jun 19, 2018

I think this may be a dupe of flutter/flutter-intellij#2351 ?

There are two emulator binaries in the SDK and IntelliJ used to use the old one (but has very recently been changed in flutter/flutter-intellij#2383) which would give this PANIC message. For flutter emulators --launch we use the new one if it exists and fall back to the old one otherwise.

So, I'd be curious to know if anyone having this issue still sees it using flutter emulators --launch from the command line. If not, then I think this case can be closed as a dupe of the above. If anyone can, then we'll need to do some more digging.

@zoechi
Copy link
Contributor

zoechi commented Dec 4, 2018

Closing as dup of flutter/flutter-intellij#2351
Please let us know if you're still seeing this problem.

@zoechi zoechi closed this as completed Dec 4, 2018
@github-actions
Copy link

github-actions bot commented Sep 1, 2021

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
platform-android Android applications specifically
Projects
None yet
Development

No branches or pull requests