Issue
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?
Solution
I have gotten it to build eventually.
The following error (and related errors)
error: package android.support.annotation does not exist
was fixed by running $ npx jetifier
from project root.
Source: https://github.com/ionic-team/capacitor/issues/1937
It is also suggested to incorporated that in a postinstall hook. Hope this helps somewhat!
Answered By - Daniel Kappelle
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.