如何解决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',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
中,我使用了 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 正在使用 .ts
的 capacitor.config.ts
扩展,现在我该如何实现这样的 "windowsAndroidStudioPath": "D:\\android-studio-canary\\bin\\studio64.exe"
。
解决方法
环境变量在您的操作系统中配置,而不是在您的应用中配置。
CAPACITOR_ANDROID_STUDIO_PATH:Android Studio 可执行文件的路径 在你的系统上。 https://capacitorjs.com/docs/config#environment-variables
如果你想知道如何在Windows中设置环境变量可以参考:
https://docs.microsoft.com/en-us/answers/questions/26223/environment-variable.html
如果你想知道如何在Linux Ubuntu中设置环境变量可以参考:
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。