简体   繁体   English

电容器:无法使用推送通知插件构建

[英]Capacitor : Can't build with push-notifications plulgin

I am trying to use the capacitor push notifications plugin in a quasar project.我正在尝试在类星体项目中使用电容器推送通知插件。 So I followedthis tutorial.所以我跟着这个教程。

But when building with the command: quasar build -m capacitor -T android outputs this error (quasar project):但是使用命令构建时: quasar build -m capacitor -T android输出此错误(类星体项目):

> Task :capacitor-push-notifications:compileReleaseJavaWithJavac FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':capacitor-push-notifications:compileReleaseJavaWithJavac'.
> invalid source release: 11

I'm not sure if the error comes from the plugin itself or if I did something wrong during the installation.我不确定错误是来自插件本身还是我在安装过程中做错了什么。 I tried redoing the tutorial from the beginning but I got the same error.我尝试从头开始重做教程,但我得到了同样的错误。

Note:笔记:

Before installing this plugin, everything was working correctly when building.在安装此插件之前,构建时一切正常。

Dev with quasar dev on web still works though but with this error: Error: "PushNotifications" plugin is not implemented on web在 web 上使用quasar dev进行开发仍然可以工作,但出现此错误: Error: "PushNotifications" plugin is not implemented on web

And quasar dev for android gives this output: android 的quasar dev给出了这个 output:

src-capacitor/node_modules/@capacitor/push-notifications/android/src/main/java/com/capacitorjs/plugins/pushnotifications/PushNotificationsPlugin.java:3: error: package android.app does not exist import android.app.Notification;

First of all.首先。 To test in dev mode and use capacitor, i think it is best to use要在开发模式下测试并使用电容器,我认为最好使用

quasar dev -m capacitor -T android quasar dev -m 电容器 -T android

So to install capacitor plugins and to test them you must install them inside src-capacitor.因此,要安装电容器插件并对其进行测试,您必须将它们安装在 src-capacitor 中。

To use capacitor plugins olso in normal dev mode you must install the plugin olso in the root folder of the quasar project.要在正常开发模式下使用电容器插件 olso,您必须将插件 olso 安装在 quasar 项目的根文件夹中。

Check your package.json inside src-capacitor检查您的 package.json 内部 src-capacitor

If you installed the 4.x version of the notification plugin you get this error.如果您安装了 4.x 版本的通知插件,则会收到此错误。

Remove the package inside src-capacitor移除 src-capacitor 内部的 package

npm remove @capacitor/push-notifications 

npx cap sync

and then reinstall by specifing the 1.0.9 version然后通过指定 1.0.9 版本重新安装

npm install @capacitor/push-notifications@1.0.9

npx cap sync

I had the same error.我有同样的错误。 The concept can be applied to many plugins.这个概念可以应用于许多插件。

StatusBar plugin also get similar error by installing the last update.通过安装上次更新,StatusBar 插件也会出现类似的错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM