Cannot build Android App once installed BackgroundGeolocation Plugin

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

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>

After that, I ran npx cap sync

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;

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

2 Likes

hi, I am following this as I need it too

I managed to solve it using Daniel Kappelle’s solution here: