使用电容安装BackgroundGeolocation插件后,无法在Android上构建Ionic App [英] Cannot build Ionic App on Android once installed BackgroundGeolocation Plugin with Capacitor

查看:172
本文介绍了使用电容安装BackgroundGeolocation插件后,无法在Android上构建Ionic App的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将我的应用程序从Cordova迁移到Capacitor,但是我仍然需要使用Background Geolocation等功能.为此,我正在使用此插件: https://ionicframework.com/docs/native/背景地理位置

I'm trying to migrate my app from Cordova to Capacitor, but I still need to use functionalities like Background Geolocation. For that, I'm using this plugin: https://ionicframework.com/docs/native/background-geolocation

因此,为了测试这一点,我创建了一个新应用,添加了Capacitor并安装了此插件.如此处所述( https://github.com/ionic-team/电容器/问题/2529#issuecomment-603205348 ),我将此行添加到了我的字符串文件中:

So, to test this, I created a fresh app, added Capacitor and installed this plugin. As mentioned here (https://github.com/ionic-team/capacitor/issues/2529#issuecomment-603205348), I added this lines to my strings file:

<string name="mauron85_bgloc_account_name">@string/app_name</string>
<string name="mauron85_bgloc_account_type">$PACKAGE_NAME.account</string>
<string name="mauron85_bgloc_content_authority">$PACKAGE_NAME</string>

那之后,我跑了npx cap sync

现在,每当我尝试构建应用程序时,都会出现以下错误: Execution failed for task ':capacitor-cordova-android-plugins:compileDebugJavaWithJavac'.

Now, whenever I'm trying to build my application, I get the following error: Execution failed for task ':capacitor-cordova-android-plugins:compileDebugJavaWithJavac'.

在我的控制台中,在此之上,有很多缺少的导入错误,如下所示:

In my console, above that, there are a lot of missing import errors, like this:

C:\Users\zxy\Desktop\mobile_apps\testApp\android\capacitor-cordova-android-plugins\src\main\java\com\evgenii\jsevaluator\JsEvaluator.java:4: error: package android.support.annotation does not exist
import android.support.annotation.VisibleForTesting;
> C:\Users\zxy\Desktop\mobile_apps\testApp\android\capacitor-cordova-android-plugins\src\main\java\com\marianhello\bgloc\BackgroundGeolocationFacade.java:17: error: package android.support.v4.content does not exist
> import android.support.v4.content.ContextCompat;
>                                  ^
> C:\Users\zxy\Desktop\mobile_apps\testApp\android\capacitor-cordova-android-plugins\src\main\java\com\marianhello\bgloc\BackgroundGeolocationFacade.java:18: error: package android.support.v4.content does not exist
> import android.support.v4.content.LocalBroadcastManager;

有什么想法可以使该插件与Capacitor一起使用吗?

Any idea how I can make this plugin to work with Capacitor?

推荐答案

我最终得到了它.

以下错误(及相关错误) error: package android.support.annotation does not exist 通过从项目根目录运行$ npx jetifier修复.

The following error (and related errors) error: package android.support.annotation does not exist was fixed by running $ npx jetifier from project root.

来源: https://github.com/ionic-team/capacitor/issues/1937

还建议将其合并到安装后挂钩中.希望这会有所帮助!

It is also suggested to incorporated that in a postinstall hook. Hope this helps somewhat!

这篇关于使用电容安装BackgroundGeolocation插件后,无法在Android上构建Ionic App的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆