英文:
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 出现错误。
我甚至没有更改代码,只是通过 pnpm install @capacitor/app
和 npx 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
<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
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
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论