Ionic 5中的CAPACITOR_ANDROID_STUDIO_PATH环境变量

mm5n2pyu  于 12个月前  发布在  Ionic
关注(0)|答案(2)|浏览(201)

已尝试将CAPACITOR_ANDROID_STUDIO_PATH环境变量添加为。

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

const config: CapacitorConfig = {
  appId: 'com.barqrscanner.app',
  appName: 'barqrscannerapp',
  webDir: 'www',
  bundledWebRuntime: false
};

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

export default config;

字符串
如果我试着把它加到。

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


将给予如下错误。

ionic build工作,但当我运行npx cap open android时,CapacitorConfigPluginsConfig都不工作,这表明了这个问题。

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.


我从这里引用它。
https://capacitorjs.com/docs/config

**更新1:**在capacitor.config.json中,我使用的是。

{
  "appId": "com.enappd.capBarcodeScanner",
  "appName": "ionic-capacitor-barcode-scanner",
  "bundledWebRuntime": false,
  "npmClient": "npm",
  "webDir": "www",
  "windowsAndroidStudioPath": "D:\\android-studio-canary\\bin\\studio64.exe",
  "cordova": {
    "preferences": {
      "ScrollEnabled": "false",
      "android-minSdkVersion": "19",
      "BackupWebStorage": "none",
      "SplashMaintainAspectRatio": "true",
      "FadeSplashScreenDuration": "300",
      "SplashShowOnlyFirstTime": "false",
      "SplashScreen": "screen",
      "SplashScreenDelay": "3000"
    }
  }
}


对于Angular 10,现在Angular 12正在使用.ts作为capacitor.config.ts的扩展,现在我如何实现像这样的"windowsAndroidStudioPath": "D:\\android-studio-canary\\bin\\studio64.exe"

8qgya5xd

8qgya5xd1#

在Ubuntu 16.04上,将此变量导出到.bashrc文件中

echo export CAPACITOR_ANDROID_STUDIO_PATH="custom-path/android-studio/bin/studio.sh" >> ~/.bashrc
source ~/.bashrc

字符串
或者在ionic cap open android之前运行

export CAPACITOR_ANDROID_STUDIO_PATH="custom-path/android-studio/bin/studio.sh"
ionic cap open android

a5g8bdjr

a5g8bdjr2#

环境变量是在您的操作系统中配置的,而不是在您的App中。
CAPACITOR_ANDROID_STUDIO_PATH:系统上Android Studio可执行文件的路径。https://capacitorjs.com/docs/config#environment-variables
如果你想知道如何在 Windows 中设置环境变量,你可以参考:
https://learn.microsoft.com/en-us/answers/questions/26223/environment-variable.html
如果你想知道如何在 Linux Ubuntu 中设置环境变量,你可以参考:
https://help.ubuntu.com/community/EnvironmentVariables

相关问题