Capacitor: bug: cordova-plugin-background-geolocation causes build failure

Created on 5 Mar 2020  路  14Comments  路  Source: ionic-team/capacitor

Bug Report

Capacitor Version

Capacitor Doctor

Latest Dependencies:

@capacitor/cli: 1.5.0

@capacitor/core: 1.5.0

@capacitor/android: 1.5.0

@capacitor/ios: 1.5.0

Installed Dependencies:

@capacitor/ios not installed

@capacitor/cli 1.5.0

@capacitor/android 1.5.0

@capacitor/core 1.5.0

Affected Platform(s)

  • [x] Android
  • [ ] iOS
  • [ ] Electron
  • [ ] Web

Current Behavior

App doesn't compile.

Expected Behavior

App compiles.

Sample Code or Sample Application Repo

Reproduction Steps

add cordova-plugin-background-geolocation to your project

Other Technical Details

Android Logcat:
Pathandroidcapacitor-cordova-android-pluginsbuildintermediateslibrary_manifestdebugAndroidManifest.xml:70:9-74:39: AAPT: error: resource string/mauron85_bgloc_content_authority (aka appid:string/mauron85_bgloc_content_authority) not found.

Other Information

Most helpful comment

The plugin relies on 3 strings that are automatically added for Cordova, but not for Capacitor.

Just add this to your strings.xml 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>

All 14 comments

What's the exact plugin id you are using and version? I can't reproduce with cordova-plugin-background-geolocation, which makes sense because it's not the mauron85 one.
can you provide a sample app?

Closing as there was no response.

Please, when reporting cordova plugin incompatibility issues, provide the npm package name or github repository.

Sorry for the late reply, I was on holiday last week.

Here is the sample repo:
https://github.com/keo9ren/cap-mauron-geolocation

It's just an stencil app with added capacitor. If you remove the geolocatoin plugin the apps compiles fine. With the plugin I've got an compiler error.

There's also an unanswered ticket filled on the geolocation repo.
https://github.com/mauron85/cordova-plugin-background-geolocation/issues/676

Really appreciate your work and hope that we can move to capacitor, at my company, soon.

Best Regards,

keo9ren

The plugin relies on 3 strings that are automatically added for Cordova, but not for Capacitor.

Just add this to your strings.xml 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>

Awesome, it works. Thanks a lot.

Where I can find strings.xml in ionic project? If I add those in android studio after build the project it automatically resets.

android\app\src\main\res\values\strings.xml

I am having a similar issue, I fixed the mauron85_bgloc_content_authority link but there are other resources failing

Android resource linking failed
androidcapacitor-cordova-android-pluginsbuildintermediateslibrary_manifestdebugAndroidManifest.xml:42:13-44:55: AAPT: error: resource xml/syncadapter (aka appid:xml/syncadapter) not found.

androidcapacitor-cordova-android-pluginsbuildintermediateslibrary_manifestdebugAndroidManifest.xml:51:13-53:57: AAPT: error: resource xml/authenticator (aka appid:xml/authenticator) not found.

Do I have to do any command to capacitor to read again the strings.xml? I'm still getting error even after including the viariables.

Same here

@jcesarmobile It works great, thanks!

The stings addition solved my mauron85_bgloc_content_authority problem but I'm getting
error: package android.support.annotation does not exist

import android.support.annotation.VisibleForTesting;
                                 ^

@jongbonga this should fix your problem: mauron85/cordova-plugin-background-geolocation#693 (comment)

I just replied to the other issue. I'm still getting

error: cannot find symbol
import androidx.core.content.LocalBroadcastManager;
                        ^
Was this page helpful?
0 / 5 - 0 ratings

Related issues

peterpeterparker picture peterpeterparker  路  3Comments

mlynch picture mlynch  路  3Comments

gnesher picture gnesher  路  3Comments

peterpeterparker picture peterpeterparker  路  3Comments

Kepro picture Kepro  路  3Comments