cordova-plugin-background-geolocation: error: failed linking file resources ...platforms\android\app\src\main\res\xml\authenticator.xml:2: AAPT: error: resource mipmap/icon (aka xxx.xxx:mipmap/icon) not found.

Your Environment

  • Plugin version: 3.0.0-alpha.50
  • Platform: Android
  • OS version: Android 9
  • Device manufacturer and model: OnePlus A3000 (oneplus 3t)
  • Running in Simulator:
  • Cordova version (cordova -v): 8.1.2 (cordova-lib@8.1.1)
  • Cordova platform version (cordova platform ls): android 8.0.0
  • Plugin configuration options:
  • Link to your project:

Context

  • What went wrong: Execution failed for task ‘:app:processDebugResources’.

Android resource linking failed …platforms\android\app\src\main\res\xml\authenticator.xml:2: AAPT: error: resource mipmap/icon (aka xx.xxx:mipmap/icon) not found.

error: failed linking file resources.

Expected Behavior

BUILD SUCCESS

Actual Behavior

BUILD FAILED

Possible Fix

Steps to Reproduce

  1. cordova create …
  2. cordova plugin add cordova-plugin-background-geolocation
  3. cordova platform add android@latest
  4. cordova run

Context

BUILD FAILING

Debug logs

This is line 2 of the file authenticator.xml

account-authenticator android:accountType=“@string/mauron85_bgloc_account_type” android:icon=“@mipmap/icon” android:label=“@string/app_name” android:smallIcon=“@mipmap/icon” xmlns:android=“http://schemas.android.com/apk/res/android

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 5
  • Comments: 37

Commits related to this issue

Most upvoted comments

Just add below line to config.xml (inside <platform name="android"> tag) This will reuse the pre-generated icon.

<resource-file src="resources/android/icon/drawable-xxxhdpi-icon.png" target="app/src/main/res/mipmap/icon.png" />

On newer API versions, you need to set SMALL_ICON and ICON to @mipmap/ic_launcher in both package.json and config.xml After that I had to recreate the android platform for it to “take”. cordova platform remove android && cordova platform add android.

Agree, actually I added the following to my config.xml: <resource-file src="assets/ic_launcher.png" target="app/src/main/res/mipmap/icon.png" />

crie pasta “mipmap” platforms\android\app\src\main\res\mipmap coloque seu icon na pasta “icon.png” pronto resolvido

create folder “mipmap” platforms\android\app\src\main\res\mipmap place your icon in the “icon.png” folder ready resolved

Agree, actually I added the following to my config.xml: <resource-file src="assets/ic_launcher.png" target="app/src/main/res/mipmap/icon.png" />

Actually for me to work I had to modify it to <resource-file src="SRC/assets/ic_launcher.png" target="app/src/main/res/mipmap/icon.png" />

and to manually copy a ‘ic_launcher.png’ resource from the path: platforms/android/app/src/main/res/mipmap-xxhdpi’ to the folder: src/assets

Reusing the “main” icon here

<icon src="res/icons/icon.png" />
<resource-file src="res/icons/icon.png" target="app/src/main/res/mipmap/icon.png" />

This declaration :

    <plugin name="@mauron85/cordova-plugin-background-geolocation" spec="3.0.3">
        <variable name="GOOGLE_PLAY_SERVICES_VERSION" value="11+" />
        <variable name="ANDROID_SUPPORT_LIBRARY_VERSION" value="26+" />
        <variable name="ICON" value="@mipmap/ic_launcher" />
        <variable name="SMALL_ICON" value="@mipmap/ic_launcher" />
        <variable name="ACCOUNT_NAME" value="@string/app_name" />
        <variable name="ACCOUNT_LABEL" value="@string/app_name" />
        <variable name="ACCOUNT_TYPE" value="$PACKAGE_NAME.account" />
        <variable name="CONTENT_AUTHORITY" value="$PACKAGE_NAME" />
    </plugin>

Works for me with :

  • cordova 8.1.2
  • cordova-android 8.0.0
  • cordova-ios 5.0.0
  • ionic cli 4.12.0

I don’t have the ALWAYS_USAGE_DESCRIPTION and MOTION_USAGE_DESCRIPTION keys because I handle iOS permission messages differently but you should include them too.

Just add below line to config.xml (inside <platform name="android"> tag) This will reuse the pre-generated icon.

<resource-file src="resources/android/icon/drawable-xxxhdpi-icon.png" target="app/src/main/res/mipmap/icon.png" />

Thanks, after two days I have managed to solve it with this.

this issue happens on cordova andoird 8 Downgrade your cordova android to 7. On my machine, it’s fixed.

cordova platform remove android cordova platform add android@^7

Agree, actually I added the following to my config.xml: <resource-file src="assets/ic_launcher.png" target="app/src/main/res/mipmap/icon.png" />

in which line you adete?

I think the solution lies just in a correct declaration in config.xml:

<plugin name="@mauron85/cordova-plugin-background-geolocation" spec="3.0.3">
    <variable name="GOOGLE_PLAY_SERVICES_VERSION" value="11.6.2" />
    <variable name="ANDROID_SUPPORT_LIBRARY_VERSION" value="26+" />
    <variable name="ICON" value="@mipmap/icon" />
    <variable name="SMALL_ICON" value="@mipmap/icon" />
    <variable name="ACCOUNT_NAME" value="@string/app_name" />
    <variable name="ACCOUNT_LABEL" value="@string/app_name" />
    <variable name="ACCOUNT_TYPE" value="$PACKAGE_NAME.account" />
    <variable name="CONTENT_AUTHORITY" value="$PACKAGE_NAME" />
    <variable name="ALWAYS_USAGE_DESCRIPTION" value="Om de drukte het op terrein te kunnen monitoren" />
    <variable name="MOTION_USAGE_DESCRIPTION" value="Om de drukte het op terrein te kunnen monitoren" />
</plugin>

This is not a good practice, you should not edit manually the content of platform folders since they can be recreated at some point (for exemple in a CI environnment).

Switching from @mipmap/icon to @mipmap/ic_launcher in your package.json and config.xml should be solution with the 3.0.0 release (don’t forget to reinstall platforms and plugins).

In my case the @mipmap/icon problem was solved by following the instructions in this example: https://github.com/oliviercherrier/mauron85-background-geolocation-example-ionic2 See the text below ‘Mimap icon missing’.

I have the same issue too. Going to roll-back to cordova 7.1.1 until this is fixed.