安装带有 Capacitor 的 BackgroundGeolocation 插件后,无法在 Android 上构建 Ionic 应用程序

2024-04-10

我正在尝试将我的应用程序从 Cordova 迁移到 Capacitor,但我仍然需要使用后台地理定位等功能。为此,我正在使用这个插件:https://ionicframework.com/docs/native/background-geolocation https://ionicframework.com/docs/native/background-geolocation

因此,为了测试这一点,我创建了一个新的应用程序,添加了 Capacitor 并安装了这个插件。正如这里提到的(https://github.com/ionic-team/capacitor/issues/2529#issuecomment-603205348 https://github.com/ionic-team/capacitor/issues/2529#issuecomment-603205348),我将此行添加到我的字符串文件中:

<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'.

在我的控制台中,上面有很多丢失的导入错误,如下所示:

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 一起使用吗?


我最终已经把它建造好了。

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

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

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

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

安装带有 Capacitor 的 BackgroundGeolocation 插件后,无法在 Android 上构建 Ionic 应用程序 的相关文章

随机推荐