Cordova-plugin-background-geolocation: https://build.phonegap.com given build error "app/src/main/res/xml/authenticator.xml:2: AAPT: error: resource mipmap/icon ( myAppId:mipmap/icon) not found"

Created on 21 Jan 2020  路  6Comments  路  Source: mauron85/cordova-plugin-background-geolocation

Hi,

I have use only one plugin that is "mauron85/cordova-plugin-background-geolocation" when buid it given error is "app/src/main/res/xml/authenticator.xml:2: AAPT: error: resource mipmap/icon (aka myAppId:mipmap/icon) not found".

I have working on latest version phonegap thiat is <preference name="phonegap-version" value="cli-9.0.0" />

and plugins are :
<plugin name="cordova-plugin-whitelist" spec="1.3.3" /> <plugin name="cordova-plugin-statusbar" spec="2.4.2" /> <plugin name="cordova-plugin-device" spec="2.0.2" /> <plugin name="cordova-plugin-splashscreen" spec="5.0.2" /> <plugin name="cordova-plugin-ionic-webview" spec="^4.0.0" /> <plugin name="cordova-plugin-ionic-keyboard" spec="^2.0.5" /> <plugin name="@mauron85/cordova-plugin-background-geolocation"/> <engine name="android" spec="^8.1.0" />

how can I solve this issue please help me.

stale

Most helpful comment

For others that stumble on this error, here is some more info on what I was doing wrong in my Ionic/Angular project. When adding the cordova-plugin-background-geolocation plugin to my project, a file called authenticator.xml in /platforms/android/app/src/main/res/xml/ is updated to include a <account-authenticator> node. This node has a number of properties based on the <cordova-plugin-background-geolocation> plugin configuration in config.xml. Making changes to the config.xml will not be reflected in authenticator.xml unless you remove and re-add the plugin (see https://www.npmjs.com/package/@mauron85/cordova-plugin-background-geolocation).

_Note: The configuration needs to be defined in config.xml before you add the plugin. Removing the plugin will remove the configuration in config.xml._

In my case, my icons were named ic_launcher.png (not icon.png), so in my config.xml file I had to configure the icon settings accordingly.

  1. Remove the plugin
    > cordova plugin remove cordova-plugin-background-geolocation
  2. Update configuration in config.xml
<plugin name="cordova-plugin-background-geolocation" spec="@mauron85/cordova-plugin-background-geolocation@^3.1.0">
  <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" />
  <variable name="ALWAYS_USAGE_DESCRIPTION" value="App requires background tracking " />
  <variable name="MOTION_USAGE_DESCRIPTION" value="App requires motion detection" />
</plugin>
  1. Re-add the plugin
    > ionic cordova plugin add cordova-plugin-background-geolocation

I guess as an alternative, you could modify the authenticator.xml file or manually add icon.png to your resources but I see these more as a hack than a robust solution.

All 6 comments

Go to the file location and rename the actual mipmap logo to icon instead. That simple :b

Actual path for me. I actually just added another file called icon.png
C:\Users\Brandon\cutt\platforms\android\app\src\main\res\mipmap-hdpi\icon.png

Hi,

The solution that worked for me was to create the platforms\android\app\src\main\res\mipmap folder and add the files inside:

  • resources\splash.png
  • resources\icon.png

https://github.com/apache/cordova-android/issues/678#issuecomment-544961990

Either way works, good stuff!

For others that stumble on this error, here is some more info on what I was doing wrong in my Ionic/Angular project. When adding the cordova-plugin-background-geolocation plugin to my project, a file called authenticator.xml in /platforms/android/app/src/main/res/xml/ is updated to include a <account-authenticator> node. This node has a number of properties based on the <cordova-plugin-background-geolocation> plugin configuration in config.xml. Making changes to the config.xml will not be reflected in authenticator.xml unless you remove and re-add the plugin (see https://www.npmjs.com/package/@mauron85/cordova-plugin-background-geolocation).

_Note: The configuration needs to be defined in config.xml before you add the plugin. Removing the plugin will remove the configuration in config.xml._

In my case, my icons were named ic_launcher.png (not icon.png), so in my config.xml file I had to configure the icon settings accordingly.

  1. Remove the plugin
    > cordova plugin remove cordova-plugin-background-geolocation
  2. Update configuration in config.xml
<plugin name="cordova-plugin-background-geolocation" spec="@mauron85/cordova-plugin-background-geolocation@^3.1.0">
  <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" />
  <variable name="ALWAYS_USAGE_DESCRIPTION" value="App requires background tracking " />
  <variable name="MOTION_USAGE_DESCRIPTION" value="App requires motion detection" />
</plugin>
  1. Re-add the plugin
    > ionic cordova plugin add cordova-plugin-background-geolocation

I guess as an alternative, you could modify the authenticator.xml file or manually add icon.png to your resources but I see these more as a hack than a robust solution.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

This issue has been automatically closed, because it has not had recent activity. If you believe this issue shouldn't be closed, please reopen or write down a comment requesting issue reopening with explanation why you think it's important. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

steveharbick picture steveharbick  路  5Comments

netbitsolutions picture netbitsolutions  路  10Comments

mahmed-ntd picture mahmed-ntd  路  10Comments

vlafranca picture vlafranca  路  6Comments

ThorvaldAagaard picture ThorvaldAagaard  路  9Comments