Getting apk build failure when using ionic-native/push and ionic-native/background-geolocation

Hi All,

I am using Ionic 3 in my project.
I am trying to use ionic-native/push plugin and ionic-native/background-geolocation

But as i build my application apk i get the build failure which says like below -

C:\wamp64\www\git_workspace\experiments\ionic3-background-geo\platforms\android\app\src\main\java\com\marianhello\bgloc\data\BackgroundActivity.java:20: error: cannot access zzbfm
        confidence = activity.getConfidence();
                             ^
  class file for com.google.android.gms.internal.zzbfm not found
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
:app:compileDebugJavaWithJavac FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

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

* Get more help at https://help.gradle.org

BUILD FAILED in 18s
28 actionable tasks: 2 executed, 26 up-to-date
cmd: Command failed with exit code 1 Error output:
C:\wamp64\www\git_workspace\experiments\ionic3-background-geo\platforms\android\app\src\main\java\com\marianhello\bgloc\data\BackgroundActivity.java:20: error: cannot access zzbfm
        confidence = activity.getConfidence();
                             ^
  class file for com.google.android.gms.internal.zzbfm not found
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

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

* Get more help at https://help.gradle.org

BUILD FAILED in 18s
[ERROR] An error occurred while running subprocess Cordova.

        Cordova build android exited with exit code 1.

        Re-running this command with the --verbose flag may provide more information.

ionic cordova plugins

> cordova plugin ls
call-number 0.0.2 "Cordova Call Number Plugin"
cordova-plugin-device 2.0.3 "Device"
cordova-plugin-ionic-keyboard 2.2.0 "cordova-plugin-ionic-keyboard"
cordova-plugin-ionic-webview 4.1.2 "cordova-plugin-ionic-webview"
cordova-plugin-mauron85-background-geolocation 3.0.0-alpha.50 "CDVBackgroundGeolocation"
cordova-plugin-sms-receive 1.0.2 "SMS Receive"
cordova-plugin-splashscreen 5.0.3 "Splashscreen"
cordova-plugin-statusbar 2.4.3 "StatusBar"
cordova-plugin-whitelist 1.3.4 "Whitelist"
cordova-plugin-x-socialsharing 5.6.0 "SocialSharing"
cordova-support-google-services 1.3.1 "cordova-support-google-services"
es6-promise-plugin 4.2.2 "Promise"
phonegap-plugin-multidex 1.0.0 "Multidex"
phonegap-plugin-push 2.3.0 "PushPlugin"

ionic info -

Ionic:

   ionic (Ionic CLI)  : 4.6.0 (C:\Users\<myuser>\AppData\Roaming\npm\node_modules\ionic)
   Ionic Framework    : ionic-angular 3.9.5
   @ionic/app-scripts : 3.2.2

Cordova:

   cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)
   Cordova Platforms     : android 7.1.4
   Cordova Plugins       : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.1.2, (and 10 other plugins)

System:

   NodeJS : v10.16.3 (C:\Program Files\nodejs\node.exe)
   npm    : 6.9.0
   OS     : Windows 10

I am not sure why is it happening?
Did anyone get into this problem? It looks like to be the firebase problem which i am using for push notification.

1 Like

just try remove the android platform by following command

ionic cordova platform remove android

and then Re Add it. Hope it will help.

I tried it already but no success :disappointed_relieved:

I think you should try creating a blank new ionic project, and then replace code src folder with the new one. Then try building it.

Yes i have followed the same way, and then found the cause that it is push notificaiton plugin giving the issue when installed with background-geolocation

I didn’t get this ? Do you mean my issue will get closed automatically

Has anyone found solution for this issue? I have exact same issue. Build works without push plugin.

Yes, my app works fine now actually you have to be careful with the ionic core version and version of the background location.

and for making it work I have to add cordova-android-play-services-gradle-release plugin to maintain stability

below are lines from my package.json file -

"@ionic-native/background-geolocation": "^4.20.0",
"@ionic-native/core": "~4.20.0",
"@mauron85/cordova-plugin-background-geolocation": "3.1.0",
"cordova-android-play-services-gradle-release": {
        "PLAY-SERVICES-LOCATION": "15.0.1"
},

config.xml have a line

    <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/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" />
    </plugin>
    <plugin name="cordova-android-play-services-gradle-release" spec="~4.0.0">
        <variable name="PLAY-SERVICES-LOCATION" value="15.0.1" />
    </plugin>

I hope it may help you.

2 Likes

I have the same problem

Hi. I wanna help. Im using capacitor. Rahjain’s answer didn’t quite work for me, but same idea… @mauron85 has to use the same PLAY-SERVICES-LOCATION version with other plugins. In my case, I had to dig in to the node_modules/@mauron85/cordova-plugin-background-geolocation/plugin.xml and change the GOOGLE_PLAY_SERVICES_VERSION default value to “15.0.1”. After running ionic cap sync… the android builds with zero errors. It works for me but I think there is better way to edit the plugin.xml for capacitor, although cordova seems to have one it their documentation.

2 Likes

Thanks, using your variable versions worked here

2 Likes

Magically worked, thanks.
<preference name="GOOGLE_PLAY_SERVICES_VERSION" default="11+"/>
changed to
<preference name="GOOGLE_PLAY_SERVICES_VERSION" default="15.0.1"/>

1 Like