Skip to content

feat: androidEmulatorStartArgs nativescript cli option - #6038

Merged
NathanWalker merged 1 commit into
NativeScript:mainfrom
Akylas:android_emulator_start
Jun 2, 2026
Merged

NathanWalker merged 1 commit into
NativeScript:mainfrom
Akylas:android_emulator_start

Conversation

@farfromrefug

@farfromrefug farfromrefug commented Jun 2, 2026 •

Copy link
Copy Markdown
Contributor

This simple PR allows to define custom Android emulator start arguments

Summary by CodeRabbit

  • New Features
    • Android emulator now supports user-configured extra start arguments, enabling customization of emulator initialization behavior.
@coderabbitai

coderabbitai Bot commented Jun 2, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

AndroidEmulatorServices now injects IUserSettingsService and asynchronously retrieves user-configured emulator start arguments when spawning. User-provided args are appended to the vendor-specific arguments, with errors silently ignored. The spawnEmulator method is converted to async, and its call site in startEmulatorCore is updated to await it.

Changes

User-configured Android emulator start arguments

Layer / File(s) Summary
Dependency injection setup
lib/common/mobile/android/android-emulator-services.ts
IUserSettingsService is imported and added as a constructor dependency injection, making the user settings service available for use during emulator startup.
Async emulator spawn integration
lib/common/mobile/android/android-emulator-services.ts
spawnEmulator is converted from a synchronous void method to an async method, and startEmulatorCore is updated to await the call instead of invoking it directly.
User settings argument retrieval
lib/common/mobile/android/android-emulator-services.ts
User-configured androidEmulatorStartArgs are fetched from settings service inside spawnEmulator, appended to startEmulatorArgs if non-empty, and any errors from the lookup are caught and silently ignored.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A hop and a wait, we've made it async,
User settings dance with emulator tasks,
Arguments append where vendors once stood,
One small change makes everything good. ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: introducing a new NativeScript CLI option for custom Android emulator start arguments.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@lib/common/mobile/android/android-emulator-services.ts`:
- Around line 199-204: The try/catch around reading androidEmulatorStartArgs
silently swallows errors; modify the block that calls
this.$userSettingsService.getSettingValue<string[]>("androidEmulatorStartArgs")
(and the subsequent startEmulatorArgs.push(...additionalArgs)) to catch errors
but log them at trace level instead of ignoring them: use the service's logger
(e.g. this.$logger.trace or equivalent) to record the caught error with context
("reading androidEmulatorStartArgs") and then continue to preserve the non-fatal
behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: e522b3f1-3dda-4388-9b46-753865e50bb3

📥 Commits

Reviewing files that changed from the base of the PR and between d1930d3 and a86433f.

📒 Files selected for processing (1)
  • lib/common/mobile/android/android-emulator-services.ts
Comment on lines +199 to +204
try {
const additionalArgs = await this.$userSettingsService.getSettingValue<string[]>("androidEmulatorStartArgs");
if (additionalArgs?.length) {
startEmulatorArgs.push(...additionalArgs);
}
} catch (error) {}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
rg -nP -C3 'interface\s+IUserSettingsService' --type=ts
ast-grep --pattern 'getSettingValue<$_>($_): $_'

Repository: NativeScript/nativescript-cli

Length of output: 464


Don’t silently swallow settings/emulator-args read errors; log at trace level.

The empty catch around androidEmulatorStartArgs retrieval (and startEmulatorArgs.push(...)) discards any failures, making misconfiguration hard to diagnose while keeping the non-fatal behavior.

♻️ Proposed change
 			try {
 				const additionalArgs = await this.$userSettingsService.getSettingValue<string[]>("androidEmulatorStartArgs");
 				if (additionalArgs?.length) {
 					startEmulatorArgs.push(...additionalArgs);
 				}
-			} catch (error) {}
+			} catch (error) {
+				this.$logger.trace(
+					`Failed to read 'androidEmulatorStartArgs' setting. More info: ${error}`,
+				);
+			}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
try {
const additionalArgs = await this.$userSettingsService.getSettingValue<string[]>("androidEmulatorStartArgs");
if (additionalArgs?.length) {
startEmulatorArgs.push(...additionalArgs);
}
} catch (error) {}
try {
const additionalArgs = await this.$userSettingsService.getSettingValue<string[]>("androidEmulatorStartArgs");
if (additionalArgs?.length) {
startEmulatorArgs.push(...additionalArgs);
}
} catch (error) {
this.$logger.trace(
`Failed to read 'androidEmulatorStartArgs' setting. More info: ${error}`,
);
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@lib/common/mobile/android/android-emulator-services.ts` around lines 199 -
204, The try/catch around reading androidEmulatorStartArgs silently swallows
errors; modify the block that calls
this.$userSettingsService.getSettingValue<string[]>("androidEmulatorStartArgs")
(and the subsequent startEmulatorArgs.push(...additionalArgs)) to catch errors
but log them at trace level instead of ignoring them: use the service's logger
(e.g. this.$logger.trace or equivalent) to record the caught error with context
("reading androidEmulatorStartArgs") and then continue to preserve the non-fatal
behavior.
@NathanWalker
NathanWalker merged commit 69ac96d into NativeScript:main Jun 2, 2026
4 checks passed
@NathanWalker
NathanWalker deleted the android_emulator_start branch June 2, 2026 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants