如何在Ubuntu上使用电容器在android-studio上运行离子应用程序?

spe*_*ker 6 android-studio ionic-framework ionic-native ionic4 capacitor

当我运行“离子电容器运行android”命令以在android studio中启动我的应用程序时,出现错误消息:

无法启动Android Studio。”,您必须使用JavaScript转义的路径,在capacitor.config.json中配置“ linuxAndroidStudioPath”以指向studio.sh的位置:例如:{“ linuxAndroidStudioPath”:“ / usr / local / android -studio / bin / studio.sh“}

但是我配置了我的电容器.config.json的路径,但错误仍然存​​在。

在此处输入图片说明

这是我的capacitor.config.json文件

在此处输入图片说明

Saj*_*ved 5

首先whereis android-studio在您的终端上运行。此命令将返回您的android studio的路径。

我的是/snap/android-studio/current/android-studio/bin/studio.sh。我从ubuntu软件商店安装了android-studio。可能您通过不同的来源和不同的位置进行安装。

然后添加"linuxAndroidStudioPath": "/snap/android-studio/current/android-studio/bin/studio.sh"位于项目根目录中的capacitor.config.json。

替换/snap/android-studio/current/android-studio/bin/studio.sh为您的路径。这是由您退还给您的whereis android-studio

我希望它会起作用。请投票。谢谢

  • 如果您使用 Typescript 而不是 JSON 作为 Capacitor 配置文件(`capacitor.config.ts`)怎么办?在“CapacitorConfig”接口中似乎没有此设置的属性。[`CapacitorConfig` 接口文档可以在这里找到](https://capacitorjs.com/docs/config) (3认同)
  • `whereis android-studio` 对我来说失败了。我宁愿做“whereis studio” (3认同)

Ren*_*Ren 5

我使用JetBrains ToolboxmacOS

要使用 Android Studio 打开电容器项目,npx cap open android我必须导出 Android Studio 路径,如下所示:

export CAPACITOR_ANDROID_STUDIO_PATH="/Users/myuser/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/201.7199119/Android Studio.app" 
Run Code Online (Sandbox Code Playgroud)


rtp*_*rry -1

一切看起来都是正确的,因此可能的答案是您不知何故路径错误。

你能再检查一下吗?

另外,您是否正在运行所有内容的最新版本?