18

I'm trying to implement the Google Maps API using the Ionic docs as seen here.

I'm using the code samples exactly as supplied, but I'm getting the following error:

BUILD FAILED

Total time: 2.748 secs

Error: /path/to/platforms/android/gradlew: Command failed with exit code 1 Error output:
/path/to/platforms/android/src/plugin/google/maps/GoogleMaps.java:479: error: cannot access AbstractSafeParcelable
        options.compassEnabled(controls.getBoolean("compass"));
               ^
  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

FAILURE: Build failed with an exception.

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

Has anyone seen/resolved this issue?

1 Answer 1

48

I was able to resolve the issue. While a lot of the suggestions I found revolved around installing missing repositories (you need Android Support Repository, Library, Play Services and Google Repository), I had all that in place. What was missing was that incorrect versioning is specified in project.properties when I used this command to add the plugin:

ionic plugin add cordova-plugin-googlemaps --variable API_KEY_FOR_ANDROID="YOUR_ANDROID_API_KEY_IS_HERE" --variable API_KEY_FOR_IOS="YOUR_IOS_API_KEY_IS_HERE"

In project.properties, I changed this:

cordova.system.library.4=com.google.android.gms:play-services-maps:9.8.0
cordova.system.library.5=com.google.android.gms:play-services-location:9.8.0

To this:

cordova.system.library.4=com.google.android.gms:play-services-maps:+
cordova.system.library.5=com.google.android.gms:play-services-location:+

That resolved the build error.

5
  • Note that this also requires that you use an emulator that can run Google Play services version 10.0 or greater. For me this meant installing the Google APIs SDK (currently listed under Android 7.0, SDK 24 in my SDK manager) and using that as the base image for the emulator. Dec 11, 2016 at 21:55
  • This is not solving my problem. 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 Dec 28, 2016 at 20:17
  • Thanks this is saved me much time.
    – RSA
    May 29, 2017 at 16:24
  • Yeah Works fine for me. Thanx @Larry Turtis Jun 20, 2017 at 4:21
  • Please have my babies. Or I'll have yours. I'm easy.
    – b4tch
    Apr 13, 2018 at 21:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.