Skip to content

Commit 71bde81

Browse files
fix: emulator 29 is not started by default
In case you have emulator with API Level 29 and other older emulators, CLI should run the latest available (29), but it doesn't. The problem is in the parsing of the string version - '9.0.0' is always newer than '10.0.0' which corresponds to API level 29. Fix the parsing, so now `tns run android` will correctly start latest available emulator in case there's nothing running.
1 parent c2aaed3 commit 71bde81

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lib/common/mobile/android/android-emulator-services.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,15 @@ export class AndroidEmulatorServices implements Mobile.IEmulatorPlatformService
144144
}
145145

146146
private getBestFit(emulators: Mobile.IDeviceInfo[]) {
147-
const best = _(emulators).maxBy(emulator => emulator.version);
147+
let best: Mobile.IDeviceInfo = null;
148+
for (const emulator of emulators) {
149+
const currentVersion = emulator.version && semver.coerce(emulator.version);
150+
const currentBestVersion = best && best.version && semver.coerce(best.version);
151+
if (!best || semver.gt(currentVersion, currentBestVersion)) {
152+
best = emulator;
153+
}
154+
}
155+
148156
const minVersion = semver.coerce(AndroidVirtualDevice.MIN_ANDROID_VERSION);
149157
const bestVersion = best && best.version && semver.coerce(best.version);
150158

0 commit comments

Comments
 (0)