带有电容器的 Ionic 和 Android 而不是 IntelliJ 中的 运行 模拟器

Ionic with capacitor and Android not running emulator in IntelliJ

我运行 npx医生和npx cap同步

   Capacitor Doctor   

 Latest Dependencies:

  @capacitor/cli: 2.2.1
  @capacitor/core: 2.2.1
  @capacitor/android: 2.2.1
  @capacitor/electron: 2.2.1
  @capacitor/ios: 2.2.1

Installed Dependencies:

  @capacitor/cli 2.2.1
  @capacitor/core 2.2.1
  @capacitor/android 2.2.1
  @capacitor/ios 2.2.1
  @capacitor/electron not installed

[success] Android looking great! 
  Found 0 Capacitor plugins for ios:
[success] iOS looking great! 
~/projects/private/growbox: ()$ npx cap open android
[info] Opening Android project at /Users//projects/private/growbox/android
~/projects/private/growbox: ()$ npx cap sync  
✔ Copying web assets from mobile to android/app/src/main/assets/public in 5.45s
✔ Copying native bridge in 10.89ms
✔ Copying capacitor.config.json in 8.76ms
✔ copy in 5.50s
✔ Updating Android plugins in 15.83ms
  Found 0 Capacitor plugins for android:
✔ update android in 86.12ms
✔ Copying web assets from mobile to ios/App/public in 5.37s
✔ Copying native bridge in 3.78ms
✔ Copying capacitor.config.json in 4.42ms
✔ copy in 5.41s
✔ Updating iOS plugins in 15.84ms
  Found 0 Capacitor plugins for ios:
✔ Updating iOS native dependencies with "pod install" (may take several minutes) in 26.92s
✔ update ios in 26.98s
✔ copy in 1.30ms
✔ update web in 5.00μp
Sync finished in 38.021s

这是我得到的,然后我 运行: npx cap open android

Got: [info] Opening Android project at /Users//projects/private/growbox/android

什么也没发生。 我有模拟器 运行 并正确安装了所有东西,我正在使用最新的 IntelliJ Ultimate

电容打开命令尝试打开AndroidStudio,如果使用IntelliJ,则需要手动打开。

有打开不同 IDE 的功能请求https://github.com/ionic-team/capacitor/issues/3242

如果您在 Linux 上 运行(下面的 Windows),要在 IntelliJ Ultimate 中打开,只需编辑 capacitor.config.json 文件并将 linuxAndroidStudioPath 添加为另一个 [ JSON 文件的 =23=] 属性:

{
     "appId": "com.foo.app",
     "appName": "FooBar",
     "bundledWebRuntime": false,
 ...
     "linuxAndroidStudioPath": "/opt/idea-IU-201.7846.76/bin/idea.sh"
}

运行

npx cap open android

如果 IntelliJ 已经打开,那么它会给出熟悉的对话框,用于在当前 window 或新的 window 中打开。

如果您 运行 在 Windows 上,看起来选项是 windowsAndroidStudioPath

Windows 参数取自 the capacitor configuration page