Cordova-plugin-background-geolocation: 2.2.5 build fails Android on Phonegap Build

Created on 14 Nov 2016  路  27Comments  路  Source: mauron85/cordova-plugin-background-geolocation

Version 2.2.2 works for Android.
2.2.5 works for iOS

Environment

  • Phonegap Build CLI 6.3.0
  • Plugin version: 2.2.5
  • Platform: Android
  • OS version: 4+
  • Cordova version (cordova -v): 6.3.0
  • Cordova platform version (cordova platform ls): android 5.2.1
  • Plugin configuration options:
    desiredAccuracy: 10,
    stationaryRadius: 20,
    distanceFilter: 30,
    maxLocations: 1000,
    // Android only section
    locationProvider: backgroundGeolocation.provider.ANDROID_ACTIVITY_PROVIDER,
    interval: 60000,
    activitiesInterval: 10000,
    notificationTitle: 'Background tracking',
    notificationText: 'enabled',
    notificationIconColor: '#FEDD1E',
    notificationIconLarge: 'mappointer_large',
    notificationIconSmall: 'mappointer_small',
    startForeground: true
  • Link to project:
    https://github.com/klaus-donnert/iDispatcher-Gps-Tracker.git

Expected Behavior

Build without error

Actual Behavior

Build failed:

Possible Fix

Steps to Reproduce

  1. fork https://github.com/klaus-donnert/iDispatcher-Gps-Tracker.git
  2. checkout branch 2.2.5 GPS Plugin test
  3. build for Android using Phonegap build CLI 6.3.0

Debug logs

Execution failed for task ':processDebugResources'.

com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/android-sdk/build-tools/24.0.1/aapt'' finished with non-zero exit value 1

bug enhancement waiting for input

All 27 comments

Could be PG is using old cordova?

Please note that as of Cordova Android 6.0.0 icons are by default in mipmap/ directory not drawable/ directory, so this plugin will have a build issue on < 6.0.0 Cordova builds, you will need to update Authenticator.xml to drawable directory from mipmap directory to work on older versions.

Could you also try 2.2.4? It's basically same as 2.2.5, but 2.2.5 was adjusted to work with new cordova android 6.0.

I think I'm having a similar issue when building for android. In my case I'm building with cordova (cordova build android).

Environment

Plugin version: 2.2.5
Cordova version: 6.4.0

Debug log

my_project_route/platforms/android/res/xml/authenticator.xml:5:19-31: AAPT: No resource found that matches the given name (at 'icon' with value '@mipmap/icon').

my_project_route/platforms/android/res/xml/authenticator.xml:6:24-36: AAPT: No resource found that matches the given name (at 'smallIcon' with value '@mipmap/icon').

Possible solution

I think the issue comes from a mismatch between what is specified in the authenticator.xml file and the content of the mipmap folders. Those folders contain files named ic_launcher.png, but the authenticator.xml file contains the following two lines:

android:icon="@mipmap/icon"
android:smallIcon="@mipmap/icon"

I tried changing those lines for the following:

android:icon="@mipmap/ic_launcher"
android:smallIcon="@mipmap/ic_launcher"

Doing that the build worked.
I guess changing the image file names from ic_launcher.png to icon.png would work too.

@JaimeFerBec That is weird. I've tried recently to create new project with latest cordova and it created icon.png in mipmap folders.

More here about it: https://github.com/mauron85/cordova-plugin-background-geolocation/issues/195#issuecomment-257041675

Can you try to reproduce? I mean, can you create new project and check if icon.png files are created?

@mauron85 This plugin has ic_launcher.png images in its resources inside its mipmap folders (in cordova-plugin-background-geolocation/android/plugin/src/main/res/). I guess I have not yet properly updated my project to generate my app's icon to the mipmap folders, and hence cordova is copying the mipmap images from this plugin's resources. This is just a guess, but the images in my android platform folder are exactly the same as the ones in this plugin. Also, it may have not happened to you because your cordova project retrieved the images from another source (probably one you specified) where the image files were called icon.png, and hence you did not get any error when building.

Anyway, I would recommend changing the image file names from ic_launcher.png to icon.png in cordova-plugin-background-geolocation/android/plugin/src/main/res/mipmap-whatever and also adding a note in the documentation to tell people that if they generate their own mipmap images they make sure they name them icon to avoid cordova build problems.

This plugin has ic_launcher.png images in its resources inside its mipmap folders (in cordova-plugin-background-geolocation/android/plugin/src/main/res/

those are there probably by mistake. I should remove those.

because your cordova project retrieved the images from another source

no, I was testing on freshly created project

Anyway, I would recommend changing the image file names from ic_launcher.png to icon.png

actually I'll remove those ic_launcher.pngs and plugin will assume that cordova create will create icon.png in mipmap folders.

EDIT:

and also adding a note in the documentation to tell people that if they generate their own mipmap images they make sure they name them icon to avoid cordova build problems.

there is already section in documentation

Please note that as of Cordova Android 6.0.0 icons are by default in mipmap/ directory not drawable/ directory, so this plugin will have a build issue on < 6.0.0 Cordova builds, you will need to update Authenticator.xml to drawable directory from mipmap directory to work on older versions.

, but I agree that it can be probably more exhaustive to cover this situation

Hello, I can confirm that downgrading to version 2.2.4 fixes the error for us.

We also have this warning (we are using Meteorjs):

WARNING: Attempting to install plugin [email protected], but it should have a minimum version of 2.3.0 to ensure compatibility with the current platform versions. Installing the minimum version for convenience, but you should adjust your dependencies.

We mainly use Android devices 4.4 and 5.1, so for now we are good.

I must say that could not stay on version 2.2.3 since it simple could not compile anymore.

can you try git master? Now it should be possible to specify path to icon within plugin declaration:

in your config.xml

<plugin name="cordova-plugin-mauron85-background-geolocation" spec="https://github.com/mauron85/cordova-plugin-background-geolocation">
    <variable name="ICON" value="@mipmap/icon" />
    <variable name="SMALL_ICON" value="@mipmap/icon" />
</plugin>

or

cordova plugin add https://github.com/mauron85/cordova-plugin-background-geolocation --variable ICON=@mipmap/icon --variable SMALL_ICON=@mipmap/smallicon

You don't need to do this, if your icon is already mipmap folder and named icon.png!

You can set ICON and SMALL_ICON to any path not just mipmap. For example with older cordova platform you can set it to: @drawable/ic_launcher

ICON and SMALL_ICON variables are only valid for sync account setup. You can check Settings -> Account -> Your App on your android device.

Don't confuse with options notificationIconLarge and notificationIconSmall as those are different things.

Other options ACCOUNT_LABEL, ACCOUNT_TYPE, CONTENT_AUTHORITY.

@mauron85 I tested the new modifications in a cordova project with android 5.2.2 and the following plugin settings:

<plugin name="cordova-plugin-mauron85-background-geolocation" spec="https://github.com/mauron85/cordova-plugin-background-geolocation.git">
        <variable name="ICON" value="@drawable/icon" />
        <variable name="SMALL_ICON" value="@drawable/icon" />
        <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="This app requires background location tracking" />
</plugin>

and it worked perfectly fine.

Thanks a lot!

glad to hear that. and you're welcome. ;-)

building with the new master e39c525 fails with:

:processReleaseResources/project/res/xml/authenticator.xml:5:19-31: AAPT: No resource found that matches the given name (at 'icon' with value '@mipmap/icon').

/project/res/xml/authenticator.xml:6:24-36: AAPT: No resource found that matches the given name (at 'smallIcon' with value '@mipmap/icon').

FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':processReleaseResources'.

com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/android-sdk/build-tools/24.0.1/aapt'' finished with non-zero exit value 1

I am not sure how to edit my config.xml. The directory structure looks like this:

gps-tree

@klaus-donnert You should take a look into platforms/android/res. What do you see in there? Probably some folders that start by drawable, and some others that start by mipmap. Take a look into the folders drawable-mdpi and mipmap-mdpi (if it exists), for instance. Take down the name of the file in those folders, which probably is either icon or ic_launcher.
Now, let's suppose that there is a file named icon.png inside the drawable folders, and that you want to make that icon the one the users sees next to your app's name when they go into Settings => Accounts in Android. If you want that to happen, edit the cordova-plugin-mauron85-background-geolocation settings in config.xml so that it includes the following two lines:

<variable name="ICON" value="@drawable/icon" />
<variable name="SMALL_ICON" value="@drawable/icon" />

Make sure you run cordova platform remove android and cordova platform add android so that the changes made to config.xml take effect.
Now your cordova project should build for android without problems.

platforms/android/res does not exist.
The platforms directory is ignored by phonegap build.
drawable-ldpi-icon.png is the smallest icon at 36 x 36
How did this plugin find the icons in 2.2.2 vs 2.2.5?
I will do a test with 2.2.4 . . .

version 2.2.4 builds without errors as expected.

@klaus-donnert How does your platforms/android folder structure looks like? Post listing of subfolder res (search for it it's nested and I don't remember exact path)

The platforms folder is ignored by phonegap build. Everything comes from the www folder.

gps_tree_icon

For the sake of completeness... This is the platform/browser/res tree. It contains the default images created when I init'd the project.

gps_platforms_tree

ok. so it might be that PGB is doing some copying from www/* (or other) folder into res. Can you unzip builded apk (it's just zip) and post it's structure. I'm specially interest in res/ folder.

apk_res_tree

Ok does mipmap* or drawable* folders contain icon.png?

drawable* have icon.png
mipmap* have ic_launcher.png

This is terrible. Latest cordova platform moved default icon.png from drawable to mipmap. But PGP is probably is using older cordova version. More about this in https://github.com/mauron85/cordova-plugin-background-geolocation/issues/195

Can you try to this configuration in your config.xml?

<plugin name="cordova-plugin-mauron85-background-geolocation" spec="https://github.com/mauron85/cordova-plugin-background-geolocation.git">
        <variable name="ICON" value="@drawable/icon" />
        <variable name="SMALL_ICON" value="@drawable/icon" />
</plugin>

Not sure if PGB supports variables though.

same error as before:

BUILD FAILED

Total time: 2.661 secs
Error: /project/gradlew: Command failed with exit code 1 Error output:
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
/project/res/xml/authenticator.xml:5:19-31: AAPT: No resource found that matches the given name (at 'icon' with value '@mipmap/icon').

/project/res/xml/authenticator.xml:6:24-36: AAPT: No resource found that matches the given name (at 'smallIcon' with value '@mipmap/icon').

While I wasn't looking, they updated phonegap build to cli-6.4.0, but they left 6.3.0 as the default.
to config.xml, I added

<preference name="phonegap-version" value="cli-6.4.0" />

and it built correctly!

Just to be clear, these were not needed
<variable name="ICON" value="@drawable/icon" />
<variable name="SMALL_ICON" value="@drawable/icon" />

because icon.png are now in the mipmap* folders

Thanks for your time and insight

I have the same issue, i've tried all of your suggestions but the problem still exists !!

Same thing here, tryed everything.. When i remove the plugin, it works

@mauron85 I tested the new modifications in a cordova project with android 5.2.2 and the following plugin settings:

<plugin name="cordova-plugin-mauron85-background-geolocation" spec="https://github.com/mauron85/cordova-plugin-background-geolocation.git">
        <variable name="ICON" value="@drawable/icon" />
        <variable name="SMALL_ICON" value="@drawable/icon" />
        <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="This app requires background location tracking" />
</plugin>

and it worked perfectly fine.

Thanks a lot!

Hi guys, sorry for bringing this back but I was hopping someone could help me, I am facing the sabe problem here.

It started showing this error about this android:icon on authenticator.xml and I had now idea the problem was on this plugin.

When I run:
% cordova compile

I get:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':processDebugResources'.
> com.android.ide.common.process.ProcessException: Failed to execute aapt

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 5.393 secs
Error: /Users/francisco/ionic-projects/jungery2/platforms/android/gradlew: Command failed with exit code 1 Error output:
/Users/francisco/ionic-projects/jungery2/platforms/android/res/xml/authenticator.xml:2:115-129: AAPT: No resource found that matches the given name (at 'icon' with value '@drawable/icon').

/Users/francisco/ionic-projects/jungery2/platforms/android/res/xml/authenticator.xml:2:150-164: AAPT: No resource found that matches the given name (at 'smallIcon' with value '@drawable/icon').

/Users/francisco/ionic-projects/jungery2/platforms/android/build/intermediates/res/merged/debug/xml/authenticator.xml:2: error: Error: No resource found that matches the given name (at 'icon' with value '@drawable/icon').

/Users/francisco/ionic-projects/jungery2/platforms/android/build/intermediates/res/merged/debug/xml/authenticator.xml:2: error: Error: No resource found that matches the given name (at 'smallIcon' with value '@drawable/icon').

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':processDebugResources'.
> com.android.ide.common.process.ProcessException: Failed to execute aapt

In the package.json I have:

      "cordova-plugin-mauron85-background-geolocation": {
        "ICON": "@drawable/icon",
        "SMALL_ICON": "@drawable/icon",
        "ACCOUNT_NAME": "@string/app_name",
        "ACCOUNT_LABEL": "@string/app_name",
        "ACCOUNT_TYPE": "$PACKAGE_NAME.account",
        "CONTENT_AUTHORITY": "$PACKAGE_NAME",
        "ALWAYS_USAGE_DESCRIPTION": "This app always requires location tracking",
        "GOOGLE_PLAY_SERVICES_VERSION": "11+",
        "ANDROID_SUPPORT_LIBRARY_VERSION": "23+"
      },

And in config.xml I have:
```











Plugins list:

卤 % cordova plugin list
com.googlemaps.ios 2.7.0 "Google Maps SDK for iOS"
com.telerik.plugins.nativepagetransitions 0.6.5 "Native Page Transitions"
cordova-plugin-add-swift-support 1.7.2 "AddSwiftSupport"
cordova-plugin-android-permissions 1.0.0 "Permissions"
cordova-plugin-camera 2.4.1 "Camera"
cordova-plugin-compat 1.2.0 "Compat"
cordova-plugin-console 1.1.0 "Console"
cordova-plugin-contacts 3.0.1 "Contacts"
cordova-plugin-crosswalk-webview 2.4.0 "Crosswalk WebView Engine"
cordova-plugin-device 2.0.2 "Device"
cordova-plugin-email-composer 0.8.15 "EmailComposer"
cordova-plugin-facebook4 1.10.1 "Facebook Connect"
cordova-plugin-file 6.0.1 "File"
cordova-plugin-geolocation 2.4.3 "Geolocation"
cordova-plugin-globalization 1.11.0 "Globalization"
cordova-plugin-googleplus 5.3.2 "Google SignIn"
cordova-plugin-ionic-keyboard 2.1.3 "cordova-plugin-ionic-keyboard"
cordova-plugin-ionic-webview 2.1.4 "cordova-plugin-ionic-webview"
cordova-plugin-linkedin 1.2.1 "LinkedIn"
cordova-plugin-mauron85-background-geolocation 2.3.6 "CDVBackgroundGeolocation"
cordova-plugin-media 5.0.2 "Media"
cordova-plugin-nativeaudio 3.0.9 "Cordova Native Audio"
cordova-plugin-nativegeocoder 2.0.5 "NativeGeocoder"
cordova-plugin-network-information 1.3.4 "Network Information"
cordova-plugin-splashscreen 5.0.2 "Splashscreen"
cordova-plugin-statusbar 2.4.2 "StatusBar"
cordova-plugin-streaming-media 2.1.3 "StreamingMedia"
cordova-plugin-whitelist 1.3.3 "Whitelist"
cordova-plugin-x-socialsharing 5.4.1 "SocialSharing"
cordova-sqlite-storage 0.7.14 "Cordova sqlite storage plugin"
es6-promise-plugin 4.2.2 "Promise"
ionic-plugin-keyboard 2.2.1 "Keyboard"
phonegap-plugin-barcodescanner 6.0.8 "BarcodeScanner"
phonegap-plugin-push 2.2.3 "PushPlugin"
twitter-connect-plugin 0.6.0 "Twitter Connect"


Ionic Info:

卤 % ionic info

cli packages: (/usr/local/lib/node_modules)

@ionic/cli-utils  : 1.19.2
ionic (Ionic CLI) : 3.20.0

global packages:

cordova (Cordova CLI) : 7.1.0

local packages:

@ionic/app-scripts : 3.2.0
Cordova Platforms  : android 6.3.0 ios 4.5.5
Ionic Framework    : ionic-angular 3.9.2

System:

Android SDK Tools : 26.1.1
ios-deploy        : 2.0.0
ios-sim           : 6.0.0
Node              : v8.11.3
npm               : 5.6.0
OS                : macOS High Sierra
Xcode             : Xcode 10.0 Build version 10A255

```

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ivent picture ivent  路  7Comments

frankzhangxd picture frankzhangxd  路  6Comments

adrieldubemarante picture adrieldubemarante  路  4Comments

kleeb picture kleeb  路  8Comments

MKHSKY picture MKHSKY  路  7Comments