首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >离子5中的CAPACITOR_ANDROID_STUDIO_PATH环境变量

离子5中的CAPACITOR_ANDROID_STUDIO_PATH环境变量
EN

Stack Overflow用户
提问于 2021-06-20 17:34:30
回答 2查看 11.1K关注 0票数 3

尝试添加CAPACITOR_ANDROID_STUDIO_PATH环境变量。

代码语言:javascript
复制
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;

如果我试图将它添加到。

代码语言:javascript
复制
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 -都不能工作,这说明了这个问题。

代码语言:javascript
复制
    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中的

代码语言:javascript
复制
{
  "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"
    }
  }
}

对于角10,现在对于角12是capacitor.config.tscapacitor.config.ts扩展,现在我如何实现类似于"windowsAndroidStudioPath": "D:\\android-studio-canary\\bin\\studio64.exe"的东西。

EN

回答 2

Stack Overflow用户

发布于 2021-09-11 09:50:15

在Ubuntu16.04上导出.bashrc文件中的这个变量

代码语言:javascript
复制
echo export CAPACITOR_ANDROID_STUDIO_PATH="custom-path/android-studio/bin/studio.sh" >> ~/.bashrc

或者在ionic cap open android之前运行

代码语言:javascript
复制
export CAPACITOR_ANDROID_STUDIO_PATH="custom-path/android-studio/bin/studio.sh"
ionic cap open android
票数 5
EN

Stack Overflow用户

发布于 2021-06-20 18:03:56

环境变量是在操作系统中配置的,而不是在应用程序中配置的。

CAPACITOR_ANDROID_STUDIO_PATH:在您的系统上到Android可执行文件的路径。https://capacitorjs.com/docs/config#environment-variables

如果您想知道如何在Windows中设置环境变量,可以参考:

https://learn.microsoft.com/en-us/answers/questions/26223/environment-variable.html

如果您想知道如何在Linux中设置环境变量,可以参考:

https://help.ubuntu.com/community/EnvironmentVariables

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68058470

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档