mauron85/cordova-plugin-background-geolocation

Build Capacitor throws error

andrewl94 opened this issue · 2 comments

Your Environment

  • Plugin version: latest
  • Platform: Android
  • OS version: MIUI11
  • Device manufacturer and model:
  • Running in Simulator:
  • Cordova version (cordova -v):
  • Cordova platform version (cordova platform ls):
  • Plugin configuration options:
  • Link to your project:

Context

I'm getting error while trying to build a capacitor version with @mauron85/cordova-plugin-background-geolocation plugin:

ERROR:

Task :capacitor-cordova-android-plugins:verifyReleaseResources FAILED

FAILURE: Build failed with an exception.

What went wrong: Execution failed for task ':capacitor-cordova-android-plugins:verifyReleaseResources'.
A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade 1 exception was raised by workers: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed C:\xampp\htdocs\xtraining\app\src-capacitor\android\capacitor-cordova-android-plugins\src\main\AndroidManifest.xml:20:1-199: AAPT: error: resource string/mauron85_bgloc_content_authority (aka capacitor.android.plugins:string/mauron85_bgloc_content_authority) not found.

I've set in my strings.xml the strings needed to run:

<string name="mauron85_bgloc_account_name">$ACCOUNT_NAME</string>
<string name="mauron85_bgloc_account_type">$ACCOUNT_TYPE</string>
<string name="mauron85_bgloc_content_authority">$CONTENT_AUTHORITY</string>

Expected Behavior

Build

Actual Behavior

Task :capacitor-cordova-android-plugins:verifyReleaseResources FAILED

FAILURE: Build failed with an exception.

What went wrong: Execution failed for task ':capacitor-cordova-android-plugins:verifyReleaseResources'.
A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade 1 exception was raised by workers: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed C:\xampp\htdocs\xtraining\app\src-capacitor\android\capacitor-cordova-android-plugins\src\main\AndroidManifest.xml:20:1-199: AAPT: error: resource string/mauron85_bgloc_content_authority (aka capacitor.android.plugins:string/mauron85_bgloc_content_authority) not found.

Possible Fix

Steps to Reproduce

  1. Install in capacitor
  2. Build

Context

Build

Debug logs

Hey @andrewl94 I have the same problem.
In the end I came up with an ugly workaround.
Created a file geolocation-strings.xml with those same strings you mentioned:

<?xml version='1.0' encoding='utf-8'?>
<resources>
    <string name="mauron85_bgloc_account_name">$ACCOUNT_NAME</string>
    <string name="mauron85_bgloc_account_type">$ACCOUNT_TYPE</string>
    <string name="mauron85_bgloc_content_authority">$CONTENT_AUTHORITY</string>
</resources>

but in my build.gradle (app) added a task to copy that file (with some others) to the $rootDir/capacitor-cordova-android-plugins/src/main/res/ where that string.xml should be

here is the main part (removed unrelated things happening in that task):

def inputDir = "$projectDir/src/main/res/"
def outputDir = "$rootDir/capacitor-cordova-android-plugins/src/main/res/"
new File(outputDir + "values/").mkdir();

def src = new File(inputDir + "values/geolocation-strings.xml")
def dst = new File(outputDir + "values/strings.xml")
dst.write(src.text)

It's terrible, I know, but my build works on appflow with capacitor.
Hope that helps :)

Thanks @vuk-nikolic . That worked for me. But ended up with another similar problem. Hope you have solution for this too.. :) I have tried writing another gradle task to copy across mipmap images from $projectDir/app/src/main/res/mipmap into $projectDir/capacitor-cordova-android-plugins/src/main/res/mipmap folder. But for some strange reason the ic_launcher.png file is not getting copied. The missing directories are getting created fine but the files are not being copied across from source to destination directory.

task copyGeoLocationMipmap(type: Copy) {
    def inputDir = "$projectDir/app/src/main/res/"
    def outputDir = "$projectDir/capacitor-cordova-android-plugins/src/main/res/"
    new File(outputDir + 'mipmap').mkdir();
    new File(outputDir + 'mipmap-hdpi').mkdir();
    new File(outputDir + 'mipmap-mdpi').mkdir();
    new File(outputDir + 'mipmap-xhdpi').mkdir();
    new File(outputDir + 'mipmap-xxhdpi').mkdir();
    new File(outputDir + 'mipmap-xxxhdpi').mkdir();

    from inputDir + 'mipmap'
    into outputDir + 'mipmap'

    from inputDir + 'mipmap-hdpi'
    into outputDir + 'mipmap-hdpi'

    from inputDir + 'mipmap-mdpi'
    into outputDir + 'mipmap-mdpi'

    from inputDir + 'mipmap-xhdpi'
    into outputDir + 'mipmap-xhdpi'

    from inputDir + 'mipmap-xxhdpi'
    into outputDir + 'mipmap-xxhdpi'

    from inputDir + 'mipmap-xxxhdpi'
    into outputDir + 'mipmap-xxxhdpi'
}

`* What went wrong:
Execution failed for task ':capacitor-cordova-android-plugins:verifyReleaseResources'.

A failure occurred while executing com.android.build.gradle.tasks.VerifyLibraryResourcesTask$Action
Android resource linking failed
ERROR:/Users/krao/Projects/multitrax-ionic6/android/capacitor-cordova-android-plugins/src/main/res/xml/authenticator.xml:7: AAPT: error: resource mipmap/ic_launcher (aka capacitor.android.plugins:mipmap/ic_launcher) not found.`