尝试将 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
中,我使用了 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/