cordova-plugin-googlemaps: Either cannot build (java exception) or get

When using the 1.4.0-beta version and the cordova-plugin-geofence plugin I get a java error. Installing one of them I can build, but installing both of them lead to an error:

compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
[...]\platforms\android\src\plugin\google\maps\PluginUtil.java:135: error: cannot access AbstractSafeParcelable
    Builder builder = LatLngBounds.builder();
                                   ^
  class file for com.google.android.gms.common.internal.safeparcel.AbstractSafeParcelable not found
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 error
:compileDebugJavaWithJavac FAILED

Reproduce with:

ionic start test --v2
cd test
ionic platform add android
ionic plugin add https://github.com/mapsplugin/cordova-plugin-googlemaps --variable API_KEY_FOR_ANDROID="..." 
ionic plugin add cordova-plugin-geofence
ionic build android

I can build when I use the following command:

ionic plugin add cordova-plugin-googlemaps --variable API_KEY_FOR_ANDROID="..." 

but then, I get a runtime exception:

my location requires permission ACCESS_FINE_LOCATION or ACCESS_COARSE_LOCATION

I home someone can help fixing either of the problems. If I should provide more info, please tell.

Regards and thanks!

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 2
  • Comments: 22 (3 by maintainers)

Most upvoted comments

For me it works with: target=android-24 cordova.system.library.1=com.google.android.gms:play-services-maps:10.0.0 cordova.system.library.2=com.google.android.gms:play-services-location:10.0.0 cordova.system.library.5=com.google.android.gms:play-services-identity:10.0.0

Thanks @wf9a5m75 I tried on a blank app and it works too!

So after all I guess it conflicts with another plugin cordova-plugin-googleplus which use the Google Play Services Lib as well.

The latest version of googlemaps plugin specified the Google Play Services version to 9.8.0 but on googleplus plugin they used “+”. After changing the plugin.xml inside cordova-plugin-googleplus it solved the problem, @ChristophRettinger you can have a try if you are using the googleplus plugin as well.

from:

<framework src="com.google.android.gms:play-services-auth:+" />
<framework src="com.google.android.gms:play-services-identity:+" />

to:

<framework src="com.google.android.gms:play-services-auth:9.8.0" />
<framework src="com.google.android.gms:play-services-identity:9.8.0" />

Don’t forget to remove android and add android to clear the cache.

@ValentinPrototype

Do you have a suggestion how we should handle the Android dependencies issues with other plugins?

The suggestion was to not pin the version in any cordova plugin. Because that is bad style and forces other plugins to use the same version this plugin has pinned. And that very version could be a buggy one. So the argument @wf9a5m75 makes is void. You specify the minimum required version (that is supposed to be bug-free) but you are not forcing others to a specific version. This concept is well established in software development. If Play Services 10.0.0 causes (caused) build errors in this plugin (don’t know which those were), then developers can themself revert playservices back to the previous version or pin this plugin (temporarily) to the old version. Who says 10.0.1 is bug free? Doesn’t gradle offer a “minimum” dependency instead of “+” and a fixed dependency?

I am very thankful for your work @wf9a5m75, this is a great plugin and it adds a lot of value to the Cordova ecosystem. That some people in this thread feel entitled to criticize something you do in your spare time is a problem with the new accessibility of Open Source. It’s especially annoying if those people do not contribute themselves.

It’s just that personally, I would accept Bugs in the Google Play Services library (which get updated very quickly) rather than figuring out how sort out dependency issues with other Cordova plugins. Since things like platforms/android/project.properties is typically not under version control and get’s overwritten when installing new plugins, I’m not sure how to handle this for distributed projects (two developers working on the same codebase) or automated builds.

Do you have a suggestion how we should handle the Android dependencies issues with other plugins?

So, what currently solves our build problem is manually setting all + to 9.8.0, likes this:

target=android-24
android.library.reference.1=CordovaLib
cordova.system.library.1=com.google.android.gms:play-services-maps:9.8.0
cordova.system.library.2=com.google.android.gms:play-services-location:9.8.0
cordova.system.library.3=com.google.android.gms:play-services-location:9.8.0
cordova.system.library.4=com.google.android.gms:play-services-auth:9.8.0
cordova.system.library.5=com.google.android.gms:play-services-identity:9.8.0

While not really a solution, it’s a temporary workaround and I hope it works for you too.