angular - Ionic 5 中的 CAPACITOR_ANDROID_STUDIO_PATH 环境变量

标签 angular typescript ionic-framework ionic5 angular12

尝试将 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'
};

会报这样的错误。 enter image description here

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 中,我使用了 as.

{
  "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 正在使用作为 capacitor.config.ts.ts 扩展 现在我如何实现这样的东西 “windowsAndroidStudioPath” : "D:\\android-studio-canary\\bin\\studio64.exe".

最佳答案

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

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

或者在 ionic cap open android 之前运行

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

关于angular - Ionic 5 中的 CAPACITOR_ANDROID_STUDIO_PATH 环境变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68058470/

相关文章:

css - 如何正确设置适合不同屏幕的 html 元素的高度?

angular - 从 angular 2 中的对象访问特定值

typescript - typescript 中 gcloud param DefineSecret 的类型 'value' 不存在属性 'SecretParam'

typescript - 在 yarn 工作区的子包中找不到 Jest

javascript - 函数中 $cordovaDialogs 的回调/ promise

jquery - 一些使用后 ionic 滚动停止工作

angular - 单击 div 内的按钮时如何禁用 div 上的 matRipple?

node.js - 使用一个 Angular 7 应用程序的多个域和子域

javascript - 使用 typescript/knockout 的 JQuery 对话框未打开

mongodb - DeprecationWarning : collection. 插入已弃用。使用 insertOne、insertMany 或bulkWrite 代替