Capacitor App Plugin不让Android Studio构建APK。

huangapple go评论76阅读模式
英文:

Capacitor App Plugin dont let android studio build the apk

问题

我正在按照此教程进行操作:https://capacitorjs.com/docs/apis/app
我完成了以下步骤:

  • 运行 pnpm install @capacitor/app
  • 运行 npx cap sync
  • 在 AndroidManifest.xml 的 activity 部分内添加以下代码:
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    <data android:scheme="@string/custom_url_scheme" />
    
  • 运行 pnpm react-scripts build && npx cap sync android && npx cap copy android && npx cap open android

我一直都是这样做的,通常能够正常构建 APK,但当我添加 Capacitor APP 插件时,Android Studio 出现错误。

android studio bug

我甚至没有更改代码,只是通过 pnpm install @capacitor/appnpx cap sync 添加了该插件。

有人经历过类似情况吗?您有任何建议吗?

我尝试过的解决方案:

  • 安装 Java SDK 17
  • 删除 android 文件夹,然后运行 npx cap add android && npx cap sync && pnpm react-scripts build && npx cap sync android && npx cap copy android && npx cap open android

我希望能够正常编译该应用/APK,我正在尝试使用返回按钮事件。

英文:

I am following the tutorial here: https://capacitorjs.com/docs/apis/app
I did the following steps:

  • pnpm install @capacitor/app
  • npx cap sync
  • added the code below inside the activity section of the AndroidManifest.xml
    &lt;action android:name=&quot;android.intent.action.VIEW&quot; /&gt;
    &lt;category android:name=&quot;android.intent.category.DEFAULT&quot; /&gt;
    &lt;category android:name=&quot;android.intent.category.BROWSABLE&quot; /&gt;
    &lt;data android:scheme=&quot;@string/custom_url_scheme&quot; /&gt;
    
  • pnpm react-scripts build && npx cap sync android && npx cap copy android && npx cap open android

I always did it that way, and it always build the apk normally, but just when I add the Capacitor APP plugin, the android studio gives an error

android studio bug

I didn't even change the code, I just added the plugin by pnpm install @capacitor/app and npx cap sync

Has anyone ever experienced this? Do you have any ideas on how to proceed?

solutions I tried:

  • install java sdk 17
  • delete the android folder and do npx cap add android && npx cap sync pnpm react-scripts build && npx cap sync android && npx cap copy android && npx cap open android

I expected to compile the app/apk normally, I'm trying to use the backButton event

答案1

得分: 0

由于我正在使用pnpm,它下载了@capacitor/app的5版本,而我的capacitor版本是4.7.1,它们不兼容,我将@capacitor/app降级到4.1.1,一切问题都解决了。

另一件事,在官方教程中,它说要添加那4行代码,但在安装应用程序时,无法打开它,也不会出现在手机的应用程序列表中,所以我不得不删除那4行代码。

英文:

As I am using pnpm, it downloaded version 5 of @capacitor/app, and my capacitor was on version 4.7.1, they are incompatible, I downgraded @capacitor/app to 4.1.1 and everything was resolved.

Another thing, in the official tutorial it says to add those 4 lines, but when installing the app, there's no way to open it and it doesn't appear in the list of apps on the phone, so I had to remove the 4 lines

huangapple
  • 本文由 发表于 2023年5月11日 07:40:57
  • 转载请务必保留本文链接:https://go.coder-hub.com/76223247.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定