Code Monkey home page Code Monkey logo

emulator's Introduction

Visual Studio Marketplace Version Installs License: MIT

Android iOS Emulator

A small Visual Studio Code extention to run Android and iOS Simulators in a click.
Link to marketplace: https://marketplace.visualstudio.com/items?itemName=DiemasMichiels.emulate

Running iOS simulators only works on Mac with Xcode!

Features

Select and run your emulator from Visual Studio Code.

Open all commands with Cmd-Shift-P and type Emulator or click the Emulator icon in the top right.

Image of Emulator

Requirements

Android Studio

To run Android emulators you need to have Android studio and already created the Android Virtual Devices.

Add the Android Studio emulator script to your settings in Visual Studio Code:
You can either set the default path or specify a specific path for each operating system. The default path will always be the fallback.
    Default: "emulator.emulatorPath": "~/Library/Android/sdk/emulator"
    Mac: "emulator.emulatorPathMac": "~/Library/Android/sdk/emulator"
    Linux: "emulator.emulatorPathLinux": "~/Android/Sdk/emulator"     Windows: "emulator.emulatorPathWindows":
      "<yourAndroidHome>\\Sdk\\emulator"
      or
      "C:\\Users\\<yourUsername>\\AppData\\Local\\Android\\Sdk\\emulator"

Your visual studio code settings are found here:
    File -> Preferences -> Setting -> User Setting -> Extensions -> Emulator Configuration

You now have the option to start Android emulators in cold boot modus. Activate it in your settings in Visual Studio Code:
    Android Cold Boot: true

Xcode

To run iOS emulators Xcode is required.

If your Xcode or simulator is not installed in the default location it is possible to set the correct path of the Simulator.app file:
"emulator.simulatorPath": "/Applications/Xcode.app/Contents/Developer/Applications/Simulator.app"

License

MIT License

Copyright (c) 2019 Diemas Michiels

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

emulator's People

Contributors

antonholmberg avatar dependabot[bot] avatar diemasmichiels avatar jarrodcolburn avatar sableangle avatar tyriar avatar wbroek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

emulator's Issues

[WSL] Extension finds emulators but does not manage to start them, but the provided command does start the emulator.

Installed the Android SDK etc under Windows. Running VSCode in WSL.

The path provided to the extension settings:

/mnt/c/Users/<user>/AppData/Local/Android/Sdk/emulator

In order for WSL to run the emulators, I have also made a copy of emulator.exe to emulator in the .../Sdk/emulator directory.

Extension returns this error:

Something went wrong running you Android emulator! Try running this command in your terminal: 
/mnt/c/Users/<user>/AppData/Local/Android/Sdk/emulator/emulator -avd Pixel_4

However running the provided command manually in the console does start the emulator successfully, making me wonder how the extension doesnt manage to start the emulator, when the command it provides does.

Furthermore, I created a minimal working example in plain js to run the provided command:

const exec = require('child_process').exec;

const cmd =
  '/mnt/c/Users/Daniel/AppData/Local/Android/Sdk/emulator/emulator -avd pixel_4';

exec(cmd);

and it perfectly opens the emulator ...

Additional information

It does find my emulators so the list-avds command seems to execute properly
emulators

Error ouput when trying to start devicce
image

[Request] Show iOS Version

If there are multiple iOS versions installed, some iOS simulators may appear duplicated. It'd be interesting to show the iOS version next to the simulator name as happens in Xcode

image

If you think this would be interesting, I'm more than happy to work on a PR.

kindly help this what vs code is telling me

Something went wrong running you Android emulator! Try running this command in your terminal: "C:\Users\Jimmy J.DESKTOP-26A9125\AppData\Local\Android\Sdk\emulator\emulator" -avd Pixel_5_API_29

Readme contains windows path with \\emulator.exe

In the README, the emulator path for windows ends with \\emulator.exe:

Windows: "emulator.emulatorPathWindows":
      "<yourAndroidHome>\\Sdk\\emulator\\emulator.exe"
      or
      "C:\\Users\\<yourUsername>\\AppData\\Local\\Android\\Sdk\\emulator\\emulator.exe"

But it does only work without the trailing \\emulator.exe. Also, the setting description says to use the path to the directory: The absolute path of the Android directory on your Windows containing the emulator scrip.

Unable to launch

My path and environment variables are set correctly.
image
I can launch the emulator just fine with flutter emulator command, but not using this extension.

Android IOS

When I press the command control P in VS Code and click on "View Android Emulator", the Emulator icon appears along with a settings icon. However, when I try to launch the emulator, I receive an error message stating that no emulator was found.

System UI isn't responding

Type: Bug

when running the flutter application in android/ios emulator a message appears says System UI isn't responding

Extension version: 1.6.0
VS Code version: Code 1.74.3 (97dec172d3256f8ca4bfb2143f3f76b503ca0534, 2023-01-09T16:59:02.252Z)
OS version: Windows_NT x64 10.0.19045
Modes:
Sandboxed: Yes

System Info
Item Value
CPUs Intel(R) Core(TM) i5-7300U CPU @ 2.60GHz (4 x 2712)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off
Load (avg) undefined
Memory (System) 7.92GB (0.71GB free)
Process Argv --crash-reporter-id ff543ee0-5a45-43cc-9cb4-f934ade32b55
Screen Reader no
VM 0%
A/B Experiments
vsliv368:30146709
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
vslsvsres303:30308271
pythonvspyl392:30443607
vserr242:30382549
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vsdfh931:30280409
vshan820:30294714
vstes263cf:30335440
vscoreces:30445986
pythondataviewer:30285071
vscod805:30301674
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
cmake_vspar411:30581797
vsaa593cf:30376535
pythonvs932:30410667
cppdebug:30492333
vsclangdf:30486550
c4g48928:30535728
dsvsc012cf:30540253
azure-dev_surveyone:30548225
pyindex848cf:30577861
nodejswelcome1:30587005
282f8724:30602487
89544117:30613380
fim-prod:30623723
a9j8j154:30646983
vscsb:30628654

Linux support

Hi, I've set up android emulators using android studio on linux. The extension is able to pick up the the emulators that I've created, but when trying to start them - the message 'Emulator is booting up' shows, disappears, and it seems like nothing happens after that.
As a side note, the emulators run in android studio.

Am I doing something wrong - or is the support for linux limited ?

Let me know if I need to provided any other information.

x86 emulators not starting up on Mac

By adding the emulator.emulatorPath provide in the README the emulator will start non x86 emulators just fine. But if you want x86 i would recommend adding

export ANDROID_SDK=$HOME/Library/Android/sdk
export PATH=$ANDROID_SDK/emulator:$ANDROID_SDK/tools:$PATH

For Mac this will work for both types of emulators. I can create a PR for this but I am not sure how this works on windows. Have anyone tried?

Errors shown when cancelling

The extension show errors when cancelling to start an emulator

  1. Error when cancelling before choosing Android or iOS
    "Failed the select OS version"

  2. Error when cancelling after choosing Android or iOS
    "Emulator failed to boot"

When you cancel, no errors should be shown

Thanks! Great work!

Exception if path has spaces

Hi, my android sdk is located on "D:\Program Files (x86)\Android\android-sdk" and when I set the emulator path for windows to "%ANDROID_HOME%\emulator" or the full path, then I become the followed exception:

Error: Command failed: D:\Program Files (x86)\Android\android-sdk\emulator\emulator -list-avds 'D:\Program' is not recognized as an internal or external command, operable program or batch file.

I have tested with and without quotation marks, but nothing works.

iOS simulator list/start not working on Xcode 13

When trying to list and/or run the iOS simulator you get an error

xcrun: error: Failed to locate 'instruments'.
xcrun: error: unable to find utility "instruments", not a developer tool or in PATH

Instruments commands have been deprecated since Xcode 11 and removed in Xcode 13.

Unable to deploy react native-app on android emulator launched through this extension

Hi there, I am working on a react-native app right now, and I am trying to deploy the app onto the android emulator launched through this extension by running react-native run-android in my project's directory through cmd.

Unfortunately, all I get is the following error from react-native cli: error Failed to launch emulator. Reason: No emulators found as an output of 'emulator -list-avds'

It sounds like adb is not aware of any running emulators if they are launched through this extension?

Launching an emulator through android studio works just fine, but I'm trying to purge android studio out of my computer so I'm migrating as much of my workflow as possible over to VS Code.

Am using a Windows 10 machine.

Not possible to use -platform qemu2 in emulator start

The recommended platform for emulator is now qemu2 rather than classic (which is a default if no -platform is specified). At least on my environment only qemu2 is configured, so attempt to launch the Android emulator results with:
PANIC: Missing emulator engine program for 'x86' CPU.
And verbose log shows:
emulator:Looking for emulator-x86 to emulate 'x86' CPU
emulator:Probing program: xxxxxx/emulator-x86.exe
PANIC: Missing emulator engine program for 'x86' CPU.

The quick solution was to add -platform qemu2 in constants.js, but it would be great if ability to pass additional invocation parameters to emulator will be added, there are more options there and maybe someone else will stumble on need of another one.

exports.ANDROID_COMMANDS = {
  LIST_AVDS: ' -list-avds',
  RUN_AVD: ' -engine qemu2 -avd ',
  RUN_AVD_COLD: ' -engine qemu2 -no-snapshot-load -avd '
}

Something went wrong fetching you android emulators

I read the other thread that's similar to this issue but mine is a little different. This is the error I'm getting:
image

And here is my emulator path:

image

It looks like the e in emulator is being recognized as a special symbol and I'm not quite sure why I have the exact path shown above pasted in User, Remote[WSL:Ubuntu], and in Workspace. I've tried different combinations of paths but I can't seem to fix this issue. Can someone please help resolve this issue? Thanks!

Cold boot for Android Emulator

Hi,
Sometimes, Android Quick Boot feature doesn't work and I have to cold boot with AVD Manager. Is it possible for you to add cold boot option to emulator? Something like when I select Android emulator, it should show Quick Boot and Cold Boot. Thanks.

Here is how I did it by quickly. You can polish it according to your coding style

constants.js

exports.ANDROID_COMMANDS = {
  LIST_AVDS: ' -list-avds',
  RUN_AVD: ' -avd ',
  RUN_AVD_COLD: ' -no-snapshot-load -avd  '
};

android.js

exports.androidPick = async () => {
  const emulators = await getAndroidEmulators();
  if (emulators) {
    const formattedEmulators = emulators.map(e => ({
      label: e.replace(/_/g, ' '),
      emulator: e
    }));
    window.showQuickPick(formattedEmulators).then(async response => {
      if (response) {
        // Another picker for Cold boot
        const options = [
          {'label':'Quick Boot','option':ANDROID_COMMANDS.RUN_AVD},
          {'label':'Cold Boot','option':ANDROID_COMMANDS.RUN_AVD_COLD}
         ]
      const emulatorWithOptions = options.map( e => ({
        label: `${response.emulator} (${e.label})`,
        option: e.option
      }));

      window.showQuickPick(emulatorWithOptions).then( async result => {
        if (result) {
          const ranEmulator = await runAndroidEmulator(response.emulator,result.option);
          if (ranEmulator) {
            showSuccessMessage('Emulator is booting up ...');
          }  
        }
      })
      }
    });
  }
};

const runAndroidEmulator = async (emulator,option) => {
  const androidPath = (await runCmd(`echo "${emulatorPath()}"`))
    .trim()
    .replace(/[\n\r"]/g, '');
  if (!androidPath) {
    return false;
  }

  const command = `${path.join(androidPath, ANDROID.PATH)}${
    option
    }${emulator}`;
  try {
    const res = await runCmd(command, {
      cwd: androidPath.replace('~', process.env.HOME)
    });
    return res || false;
  } catch (e) {
    showErrorMessage(e.toString());
    showErrorMessage(
      `Something went wrong running you Android emulator! Try running this command in your terminal: ${command}`
    );
    return false;
  }
};

Couldn't add path to VScode

I use Windows 10, so I added the path "C:\Users\LENOVO\AppData\Local\Android\sdk\emulator\emulator.exe" to the vscode settings.

I have installed the sdk but still says that the path is wrong. When I looked deeper, I found that with adding the path and extra word addsin( "emulatore" ) eventhough i dint mention it.

I have attached the screenshot of the error.

Screenshot (59)

Emulated device does not display new changes.

I have installed the extension and configured the path to my emulator:
Screenshot from 2022-11-05 13-01-31

What I've noticed when running emulator that it does not show any recent changes made in VSCode. I tested it by changing .xml file and emulator showed me old version of .xml. However, if I run emulator using Android Studio first and run VSCode emulator next - all changes are shown as they should.

Is there anything I need to configure to have my changes being shown by VSCode emulator?

Forgot to mention, I've tried reinstalling application and setting path to the emulator again - didn't work for me.

Thank you.

The "Emulator(Ctrl+Alt+E)" does not work on windows 10

Type: Bug

After click the icon or use "Ctrl+Alt+E", select 'View Android emulators' can't find my emulator. There is a popup window display the following error message:
Something went wrong fetching you Android emulators! Make sure your path is correct. Try running this command in your terminal: "false\emulator" -list-avds

What's the "false\emulator" -list-avds command, I can't run it on windows 10.

So I can't start my Android emulator wiht this icon on windows 10.

But when using ' emulator -avd Pixel_2_API_27' in powershell, it works.

The emulator device path is 'C:\Users\jxlia.android\avd\Pixel_2_API_27.avd'

The emulator.exe path is C:\Users\jxlia\AppData\Local\Android\Sdk\emulator

emulator_issue

Extension version: 1.6.0
VS Code version: Code 1.72.0 (64bbfbf67ada9953918d72e1df2f4d8e537d340e, 2022-10-04T23:20:39.912Z)
OS version: Windows_NT x64 10.0.19044
Modes:
Sandboxed: No

System Info
Item Value
CPUs Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz (4 x 2904)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off
Load (avg) undefined
Memory (System) 11.91GB (4.33GB free)
Process Argv --crash-reporter-id 0d1499e7-be8f-424e-a7eb-ad9ea9c3dc11
Screen Reader no
VM 0%
A/B Experiments
vsliv368:30146709
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
vstes627cf:30244335
vslsvsres303:30308271
pythonvspyl392:30443607
vserr242cf:30382550
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vshan820:30294714
vstes263:30335439
vscorecescf:30445987
pythondataviewer:30285071
vscod805:30301674
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
cmake_vspar411:30581797
vsaa593cf:30376535
pythonvs932:30410667
cppdebug:30492333
vsclangdf:30486550
c4g48928:30535728
dsvsc012:30540252
azure-dev_surveyone:30548225
i497e931:30553904
pyindex848:30577860
fc301958:30573243

Something went wrong fetching you Android emulators

When i view list android emulator, i got 2 messages:

  • Something went wrong fetching you Android emulators! Make sure your path is correct. Try running this command in your terminal: C:\Users\HUNG\AppData\Local\Android\Sdk\emulator\emulator.exe\emulator -list-avds

  • Error: spawn C:\WINDOWS\system32\cmd.exe ENOENT

My emulator path in the setting is correct.

C:\Users\HUNG\AppData\Local\Android\Sdk\emulator\emulator.exe

How to resolve it ?
Sorry if you don't understand. My english is very bad ^_^

6

We have written the needed data into your clipboard because it was too large to send. Please paste.

Check in extension debug configuration

No .vscode/launch.json is checked in which makes debugging the extension difficult. Normally you just press F5 in VS Code to build and debug extensions.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.