cordova-plugin-googlemaps: Map won't load

I’m submitting a … (check one with “x”)

  • question
  • any problem or bug report

OS: (check one with “x”)

  • Android
  • iOS
  • Browser

cordova information: (run $> cordova plugin list)

com.rsginc.exceptionthrower 1.0.0 "com.rsginc.exceptionthrower"
com.rsginc.heartbeat 1.0.0 "Heartbeat"
com.rsginc.mobilesurvey 1.0.0 "Trip Recorder guts"
com.rsginc.proguard 2.0.0 "Cordova plugin ProGuard"
cordova-android-play-services-gradle-release 4.0.0 "cordova-android-play-services-gradle-release"
cordova-androidx-build 1.0.4 "cordova-androidx-build"
cordova-plugin-androidx-adapter 1.1.3 "cordova-plugin-androidx-adapter"
cordova-plugin-app-version 0.1.9 "AppVersion"
cordova-plugin-device 2.0.2 "Device"
cordova-plugin-firebase-analytics 6.1.0 "FirebaseAnalyticsPlugin"
cordova-plugin-firebase-crash 4.2.0 "cordova-plugin-firebase-crash"
cordova-plugin-googlemaps 2.8.0-20200709-2008 "cordova-plugin-googlemaps"
cordova-plugin-idfa 2.0.0 "cordova-plugin-idfa"
cordova-plugin-inappbrowser 4.1.0 "InAppBrowser"
cordova-plugin-ionic-keyboard 2.2.0 "cordova-plugin-ionic-keyboard"
cordova-plugin-ionic-webview 4.2.1 "cordova-plugin-ionic-webview"
cordova-plugin-localization-strings 3.2.1 "Localization"
cordova-plugin-network-information 2.0.2 "Network Information"
cordova-plugin-request-location-accuracy 2.3.0 "Request Location Accuracy"
cordova-plugin-screen-orientation 3.0.2 "Screen Orientation"
cordova-plugin-splashscreen 5.0.2 "Splashscreen"
cordova-plugin-statusbar 2.4.2 "StatusBar"
cordova-sqlite-storage 5.1.0 "Cordova sqlite storage plugin - cordova-sqlite-storage plugin version"
cordova-support-android-plugin 1.0.2 "cordova-support-android-plugin"
es6-promise-plugin 4.2.2 "Promise"

If you use @ionic-native/google-maps, please tell the package.json (only @ionic-native/core and @ionic-native/google-maps are fine mostly)

"@ionic-native/core": "^5.0.0"
"@ionic-native/google-maps": "^5.5.0"

Current behavior:

The map doesn’t load. I traced the JS code, and it seems to call through to the Java code, but a breakpoint in the Java code shows the CordovaGoogleMaps execute function is not being called. I’m not positive this is relevant, but I do get an info-level log line:

oneway function results for code 2 on binder at 0xb400006f430c36d0 will be dropped but finished with status UNKNOWN_TRANSACTION

Expected behavior: Map should load

Related code, data or error log (please format your code or data):

I upgraded to cordova-android 10 and I’m targeting the Android SDK 31; those are the changes I made right before this stopped working.

Support this plugin activity

I appreicate if you give me a beer 🍺 from here

About this issue

Commits related to this issue

Most upvoted comments

I’m also experiencing this issue (map staying blank) after upgrading cordova-android from 8 to 11. I debugged the native code and found that the initial call to getMap is failing ad the following line in CordovaGoogleMaps.java

pluginManager.addService(pluginEntry);

The cause seems to be that pluginEntry contains a Cordova plugin instance that is already initialized, and the addService methods attempts to initialize it again This is triggering a Java assert in CordovaPlugin.java

assert this.cordova == null;

If I build the app for release, the map appears correctly (since assertions are never run in release mode).

The strange thing is that the code was identical in cordova-android@8, but the assertion was not firing in debug mode. My guess Is that assertions were previously always disabled in Android and are now enabled thanks to the new Android API/VM.

@keev-studio please see this commit on our fork: webratio/phonegap-plugin-googlemaps@66e8d2607e88e0318c750f2c0c6ca1d778907ad4.

The fix for now is very very hacky. Basically I null out the cordova field, so the Java assertion does not fail. The advantage is that this fix is very safe, since I am not changing the creation and initialization of helper CordovaPlugin objects.

Ideally, we should fix the problem by not requiring an explicit initialization of the various plugin objects (i.e. calls to privateInitialize) but that would require larger changes to the GoogleMaps plugin.