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

Unable to start emulator from VS Code #1646

Open
HobDev opened this issue Nov 28, 2024 · 11 comments
Open

Unable to start emulator from VS Code #1646

HobDev opened this issue Nov 28, 2024 · 11 comments
Assignees
Labels
area-maui bug Something isn't working mac MacOS

Comments

@HobDev
Copy link

HobDev commented Nov 28, 2024

Type: Bug

Getting the following error when trying to debug a new .NET Mau project.
[{
"resource": "/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/35.0.7/tools/Xamarin.Android.Common.Debugging.targets",
"owner": "maui",
"code": "XA0010",
"severity": 8,
"message": "Selected device is not running.",
"startLineNumber": 333,
"startColumn": 5,
"endLineNumber": 333,
"endColumn": 5
}]

Extension version: 1.5.34
VS Code version: Code 1.95.3 (Universal) (f1a4fb101478ce6ec82fe9627c43efbf9e98c813, 2024-11-13T14:50:04.152Z)
OS version: Darwin arm64 24.1.0
Modes:

System Info
Item Value
CPUs Apple M2 (8 x 2400)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
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_graphite: disabled_off
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) 3, 3, 3
Memory (System) 8.00GB (0.43GB free)
Process Argv --crash-reporter-id 421570d0-a5c4-4849-848c-c96780d2457e
Screen Reader no
VM 0%
A/B Experiments
vsliv368:30146709
vspor879:30202332
vspor708:30202333
vspor363:30204092
vscod805:30301674
binariesv615:30325510
vsaa593:30376534
py29gd2263:31024239
c4g48928:30535728
azure-dev_surveyone:30548225
962ge761:30959799
pythonnoceb:30805159
asynctok:30898717
pythonmypyd1:30879173
2e7ec940:31000449
pythontbext0:30879054
cppperfnew:31000557
dsvsc020:30976470
pythonait:31006305
dsvsc021:30996838
da93g388:31013173
dvdeprecation:31068756
dwnewjupytercf:31046870
nativerepl2:31139839
pythonrstrctxt:31112756
cf971741:31144450
iacca1:31171482
notype1:31157159
5fd0e150:31155592
dwcopilot:31170013
stablechunks:31184530

@webreidi webreidi added bug Something isn't working area-maui mac MacOS labels Dec 2, 2024
@mauroa
Copy link
Member

mauroa commented Dec 2, 2024

Hi @HobDev,

Did you try manually starting the Android emulator and see if it runs correctly? Also, could you try creating and running another emulator and see if it makes any difference? Thanks

@mauroa mauroa added the needs-more-info Needing more information, waiting on OP label Dec 2, 2024
@mauroa
Copy link
Member

mauroa commented Dec 5, 2024

Assigning to @tondat to take a first look, related to #1661

@tondat tondat marked this as a duplicate of #1661 Dec 16, 2024
@tondat
Copy link
Member

tondat commented Dec 16, 2024

@HobDev in order to understand the issue please share the following information:

  1. was the emulator launched by vscode or it was launched from a different tool or from terminal?
  2. set the Debug Verbosity to diagnostics, that will generate the binlog (on root solution folder) for the build:
Image
  1. try repro (debug the app)
  2. run on terminal the command: '{Your android-ask path}/platform-tools/adb devices'. That provide the information about the status of emulator (detected/connected to adb).
  3. attach the binlog and the result of the command
  4. if the emulator is running (you can use it), and you retry the debug. Debugging works?

We look forward to hearing from you!

@HobDev
Copy link
Author

HobDev commented Dec 21, 2024

@tondat
I can debug the app when the emulator is running. I installed the emulator from command line and start it from command line too using the command emulator -avd name-of-your-emulator. Actually this is feature request which is similar to #1661.

The binlog file from the solution when I debugged without starting the emulator:
msbuild.zip

Run the abd devices command in the platform-tools folder of Android sdk. The result is below:

C:\Users\spara\AppData\Local\Android\Sdk\platform-tools>abd devices
'abd' is not recognized as an internal or external command,
operable program or batch file.

@github-actions github-actions bot removed the needs-more-info Needing more information, waiting on OP label Dec 21, 2024
Copy link

@mauroa, the 'needs-more-info' label has been removed upon receiving further response from the original bug filer.

@tondat
Copy link
Member

tondat commented Dec 27, 2024

@HobDev please try run './adb devices'.

The bug was reported on MacOS.
You are trying the repro on windows now?

@HobDev
Copy link
Author

HobDev commented Jan 2, 2025

@tondat

The binlog file from the solution when I debugged without starting the emulator on macOS:msbuild.binlog.zip

Run the abd devices command in the platform-tools folder of Android sdk on Windows as well as MacOS. The command return the following text without any devices name.

List of devices attached

@HobDev
Copy link
Author

HobDev commented Jan 8, 2025

I deleted Android SDK and emulators from my Mac and reinstall it using Android Studio. Now I able to start the emulator from the VS Code. I don't know the actual cause due to which the emulator was not starting from VS Code previously. But it's working fine now after installing Android Studio.

@tondat
Copy link
Member

tondat commented Jan 8, 2025

@HobDev

The reported build error
"XA0010: Selected device is not running" is because the emulator that you are trying to use is not connected to ADB.
The MSBuild parameter "AdbTarget = -s MyAndroidVirtualDevice-API35" has an invalid value, it has the name of the emulator, but the Android target wait the id assigned by ADB when the emulator is running.

The command adb devices confirm that the emulator is not running (empty result).

I need the following information to understand how you arrive to this situation:
1- how are you set the debug target? are you using the debug target picker or are you using a static value on ".vscode/launch.json" file?
2- how are you launching the emulator? vscode debug process (when you press F5) automatically launch it or you are launching the emulator from terminal?
3- please attach the '.NET MAUI' output content.

@HobDev
Copy link
Author

HobDev commented Jan 9, 2025

1- I am using debug target picker ({}) in the Status Bar to set the debug target and startup project
2- I am launching the emulator from Debug Button in the Run and Debug View of the Activity Bar.
3- The .NET MAUI out put content is pasted below:

ANDROID ENVIRONMENT STATUS: 09/01/2025, 08:59:18
 
Here is the status of your Android development environment:
 
Required components:
 
	✓ Java SDK - INSTALLED (version '17.0.13')
		- Path: '/Library/Java/JavaVirtualMachines/microsoft-17.jdk/Contents/Home' (VSCode settings)

	✓ Android SDK - INSTALLED
		- Path: '/Users/paramjit/Library/Android/sdk' (VSCode settings)
 
		✓ platforms/android-34 - INSTALLED (version '3')
		✓ build-tools/34.0.0 - INSTALLED (version '34.0.0')
		✓ platform-tools - INSTALLED (version '35.0.2')
		✓ cmdline-tools/11.0 - INSTALLED (version '17.0')
 
Optional components:
 
	✓ Android Virtual Device (AVD) - COMPLETE
		- AVD Path: '/Users/paramjit/.android/avd'
		- AVD devices - DETECTED ('Pixel8API34','MyAnroiVirtulDeice-API35')
 
		✓ emulator - INSTALLED (version '35.2.10')
		✓ system-images/android-34/google_apis/arm64-v8a - INSTALLED (version '14')
		✓ system-images/android-34/google_apis_playstore/arm64-v8a - INSTALLED (version '14')
		✓ system-images/android-35/google_apis/arm64-v8a - INSTALLED (version '8')
 
IMPORTANT:
- If you are sharing the Android SDK location with Android Studio, the recommended way to install/update the SDK and accept licenses is by using Android Studio.
 
 
Xcode:
	- Path: /Applications/Xcode.app
	- Discovered from: xcode-select -p
	- Installed: true
 
No compatible .NET runtime found. Minimum required version is 8.0.3
Failed to find a compatible .NET runtime, falling back to acquire it via ms-dotnettools.vscode-dotnet-runtime. See the .NET Runtime output for more information
Using .NET runtime: '/Users/paramjit/Library/Application Support/Code/User/globalStorage/ms-dotnettools.vscode-dotnet-runtime/.dotnet/8.0.11~arm64'
ANDROID ENVIRONMENT STATUS: 09/01/2025, 09:03:46
 
Here is the status of your Android development environment:
 
Required components:
 
	✓ Java SDK - INSTALLED (version '17.0.13')
		- Path: '/Library/Java/JavaVirtualMachines/microsoft-17.jdk/Contents/Home' (VSCode settings)

	✗ Android SDK - UPDATE REQUIRED
		- Path: '/Users/paramjit/Library/Android/sdk' (VSCode settings)
 
		✓ platforms/android-34 - INSTALLED (version '3')
		✓ build-tools/34.0.0 - INSTALLED (version '34.0.0')
		✓ platform-tools - INSTALLED (version '35.0.2')
		✓ cmdline-tools/11.0 - INSTALLED (version '17.0')
		✗ ndk-bundle - NOT INSTALLED
 
Optional components:
 
	✓ Android Virtual Device (AVD) - COMPLETE
		- AVD Path: '/Users/paramjit/.android/avd'
		- AVD devices - DETECTED ('Pixel8API34','MyAnroiVirtulDeice-API35')
 
		✓ emulator - INSTALLED (version '35.2.10')
		✓ system-images/android-34/google_apis/arm64-v8a - INSTALLED (version '14')
		✓ system-images/android-34/google_apis_playstore/arm64-v8a - INSTALLED (version '14')
		✓ system-images/android-35/google_apis/arm64-v8a - INSTALLED (version '8')
 
IMPORTANT:
- If you are sharing the Android SDK location with Android Studio, the recommended way to install/update the SDK and accept licenses is by using Android Studio.
 
ACTION REQUIRED:
✗- Android SDK - Ensure that the required Android SDK components are installed: "ndk-bundle".
	1. Install the Android SDK components:
		- From the command palette, choose '.NET MAUI: Configure Android', select 'How to configure Android', and follow the instructions.
		- Alternatively, you can try installing the components by opening a Terminal, navigating to directory '/Users/paramjit/Library/Android/sdk/cmdline-tools/latest/bin' and then running: './sdkmanager "ndk-bundle"'. Then, from the command palette, choose '.NET MAUI: Configure Android', and 'Refresh Android environment'.
Take into account that the .NET MAUI Android SDK recommends specific component versions and if you decide to not use them the building and debugging may not work well.
 
 
Emulator Pixel 8 API 34 (identifier: emulator-5554) is running.

@HobDev
Copy link
Author

HobDev commented Jan 9, 2025

@tondat
I didn't understand the two issues in the above output.
1- No compatible .NET runtime found. Minimum required version is 8.0.3- I have installed .net 9 sdk and it should build and run the .net 8 project.
2- ✗- Android SDK - Ensure that the required Android SDK components are installed: "ndk-bundle". - the NDK (Side by side) version 27.2.12479018 is already installed from Android studio

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-maui bug Something isn't working mac MacOS
Projects
None yet
Development

No branches or pull requests

4 participants