CAPACITOR_ANDROID_STUDIO_PATH environment variable in Ionic 5

Tried to add CAPACITOR_ANDROID_STUDIO_PATH environment variable as.

import { CapacitorConfig } from '@capacitor/cli';

const config: CapacitorConfig = {
  appId: 'com.barqrscanner.app',
  appName: 'barqrscannerapp',
  webDir: 'www',
  bundledWebRuntime: false,
CAPACITOR_ANDROID_STUDIO_PATH: 'D:\\android-studio-canary\\bin\\studio64.exe'
};

export interface PluginsConfig {
  [CAPACITOR_ANDROID_STUDIO_PATH: string]: | {
        [CAPACITOR_ANDROID_STUDIO_PATH: string]: 'D:\\android-studio-canary\\bin\\studio64.exe';
      }
    | undefined;
}

export default config;

None of it worked showed only this.

PS D:\Projects\BarQrScannerApp> npx cap open android
[error] Unable to launch Android Studio. Is it installed?
        Attempted to open Android Studio at:
        You can configure this with the CAPACITOR_ANDROID_STUDIO_PATH environment variable.

I’ve used Angular 10 with path set as "windowsAndroidStudioPath": "D:\\android-studio-canary\\bin\\studio64.exe",
which works flawlessly but in the Angular 12 it doesn’t work.
There is a change in it as well capacitor.config.json is now capacitor.config.ts in Angular 12,
so how do I fit the windowsAndroidStudioPath or this CAPACITOR_ANDROID_STUDIO_PATH.
The reference I took is this Config path

It’s an environment variable, not a configuration option in capacitor config file.

windowsAndroidStudioPath like this can anything be similarly done to run the studio64.exe within the capacitor.config.ts file which was used in Angular 10 rather than using the environment in windows?

As I’m trying to run the following command npx cap open android it shows this error

PS D:\Projects\BarQrScannerApp> npx cap open android
[error] Unable to launch Android Studio. Is it installed?
Attempted to open Android Studio at:
You can configure this with the CAPACITOR_ANDROID_STUDIO_PATH environment variable.

Even though I’ve added as CAPACITOR_ANDROID_STUDIO_PATH: 'D:\\android-studio-canary\\bin\\studio64.exe' in the Environment variable.


It still doesn’t work

are you using cmd or other terminal?

I’ve been testing on CMD and it’s working fine, I installed Android Studio canary and I’ve been switching the value to open canary or regular without problems, but you need to close the CMD and open a new one so it picks the values after you set/change them.

1 Like