| 9 | const debug = Debug('capacitor:android:open'); |
| 10 | |
| 11 | export async function openAndroid(config: Config): Promise<void> { |
| 12 | const androidStudioPath = await config.android.studioPath; |
| 13 | const dir = config.android.platformDirAbs; |
| 14 | |
| 15 | try { |
| 16 | if (!(await pathExists(androidStudioPath))) { |
| 17 | throw new Error(`Android Studio does not exist at: ${androidStudioPath}`); |
| 18 | } |
| 19 | |
| 20 | await open(dir, { app: { name: androidStudioPath }, wait: false }); |
| 21 | logger.info(`Opening Android project at: ${c.strong(config.android.platformDir)}.`); |
| 22 | } catch (e) { |
| 23 | debug('Error opening Android Studio: %O', e); |
| 24 | |
| 25 | logger.error( |
| 26 | 'Unable to launch Android Studio. Is it installed?\n' + |
| 27 | `Attempted to open Android Studio at: ${c.strong(androidStudioPath)}\n` + |
| 28 | `You can configure this with the ${c.input('CAPACITOR_ANDROID_STUDIO_PATH')} environment variable.`, |
| 29 | ); |
| 30 | } |
| 31 | } |