angular - Ionic 5 中的 CAPACITOR_ANDROID_STUDIO_PATH 环境变量
问题描述
试图将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
它们CapacitorConfig
并且PluginsConfig
不起作用时,它显示了这个问题。
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"
。
解决方案
在 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
推荐阅读
- xamarin - Xamarin 表单可以在 ContentPage 上绘制 ContentPage?
- r - 如何在 Windows 上的 R 中加载 Keras 模型?
- asp.net-core - 从浏览器请求返回 NotFound 或 BadRequest
- autohotkey - 如何在 AHK 的 3d 游戏中移动模拟鼠标以移动十字准线?
- excel - 如何计算 Power Query o Excel 表中日期时间之间的销售额
- android - KTOR 文件上传示例有什么问题?
- c++ - 将.csv读入`map
>` - sql - 在 Oracle SQL 中根据顺序分离结果
- python - 基于二进制掩码opencv改变像素颜色
- git - 编译多个版本的 C 程序进行测试