mapsplugin / cordova-plugin-googlemaps

Google Maps plugin for Cordova
Apache License 2.0
1.66k stars 915 forks source link

"'isAvailable' is not defined in GoogleMaps plugin." on device ready #2836

Open manivelponnusamy opened 3 years ago

manivelponnusamy commented 3 years ago

I'm submitting a ... (check one with "x")

If you choose 'problem or bug report', please select OS: (check one with "x")

cordova information: (run $> cordova plugin list)

adobe-mobile-services 4.13.1 "ADBMobile"
card.io.cordova.mobilesdk 2.1.0 "CardIO"
com.abdsoft.Hash 0.1.0 "Hash"
com.googlemaps.ios 2.3.0 "Google Maps SDK for iOS"
com.localytics.phonegap.LocalyticsPlugin 5.6.0 "Localytics"
com.omarben.inappreview 0.0.5 "inappreview"
com.wongatech.cordova-disable-nsurl-cache 0.0.1-dev "CordovaDisableNSURLCache"
cordova-android-firebase-gradle-release 2.1.0 "cordova-android-firebase-gradle-release"
cordova-android-play-services-gradle-release 2.1.0 "cordova-android-play-services-gradle-release"
cordova-disable-http-cache 1.0.0 "Cordova HTTP cache disabler"
cordova-launch-review 3.1.0 "Launch Review"
cordova-open-native-settings 1.5.2 "Native settings"
cordova-plugin-app-event 1.2.0 "Application Events"
cordova-plugin-appavailability 0.4.2 "AppAvailability"
cordova-plugin-appsflyer-sdk 4.4.22 "AppsFlyer"
cordova-plugin-badge 0.8.7 "Badge"
cordova-plugin-calendar 5.0.0 "Calendar"
cordova-plugin-cloud-settings 1.0.4 "cordova-plugin-cloud-settings"
cordova-plugin-console 1.1.0 "Console"
cordova-plugin-crypt-file 1.3.3 "CordovaCrypt"
cordova-plugin-customurlscheme 4.3.0 "Custom URL scheme"
cordova-plugin-datepicker 0.9.3 "DatePicker"
cordova-plugin-device 1.1.1 "Device"
cordova-plugin-dialogs 1.2.2-dev "Notification"
cordova-plugin-enable-multidex 0.2.0 "Enable Multidex"
cordova-plugin-facebook4 1.9.1 "Facebook Connect"
cordova-plugin-file 6.0.2 "File"
cordova-plugin-geolocation 2.1.0 "Geolocation"
cordova-plugin-globalization 1.0.2 "Globalization"
cordova-plugin-googlemaps 1.4.0 "phonegap-googlemaps-plugin"
cordova-plugin-hockeyapp 5.2.0 "HockeyApp"
cordova-plugin-inappbrowser 3.2.0 "InAppBrowser"
cordova-plugin-local-notifications 0.9.0-beta.0 "LocalNotification"
cordova-plugin-localization-strings 2.0.0 "Localization"
cordova-plugin-ms-appinsights 0.0.2 "Application Insights"
cordova-plugin-nativeclicksound 0.0.3 "Native Click Sound"
cordova-plugin-network-information 1.2.0 "Network Information"
cordova-plugin-proguard 2.2.0 "Cordova plugin ProGuard"
cordova-plugin-splashscreen 5.0.2 "Splashscreen"
cordova-plugin-statusbar 2.1.0 "StatusBar"
cordova-plugin-touch-id 3.2.0 "Touch ID"
cordova-plugin-update-security-provider 1.0.0 "UpdateSecurityProviderPlugin"
cordova-plugin-whitelist 1.2.1 "Whitelist"
cordova.plugins.diagnostic 4.0.3 "Diagnostic"
dynatrace-cordova-plugin 7.2.4 "Dynatrace"
ionic-plugin-deeplinks 1.0.14 "Ionic Deeplink Plugin"
ionic-plugin-keyboard 1.0.8 "Keyboard"
skwas-cordova-plugin-datetimepicker 2.1.1 "DateTime picker"
tealium-cordova-plugin 1.1.2 "TealiumCordova"

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

Current behavior: I am developing Cordova app and am using this plugin to display google map. Recently I have upgraded my app Android API Level to 29 using Cordova Android version 9.0.0. I was using Android@8.0.0 (Android API Level 28) and google map is working fine. After upgrade my Cordova Android platform version to 9.0.0 and using AndroidX, google map is not working. And getting the below error

java.lang.NoSuchMethodException: plugin.google.maps.GoogleMaps.isAvailable [class org.json.JSONArray, class org.apache.cordova.CallbackContext]
2020-10-19 17:48:08.876 25964-25964/com.avis.mobile W/System.err:     at java.lang.Class.getMethod(Class.java:2072)
2020-10-19 17:48:08.876 25964-25964/com.avis.mobile W/System.err:     at java.lang.Class.getDeclaredMethod(Class.java:2050)
2020-10-19 17:48:08.876 25964-25964/com.avis.mobile W/System.err:     at plugin.google.maps.GoogleMaps$h.run(SourceFile:271)
2020-10-19 17:48:08.877 25964-25964/com.avis.mobile W/System.err:     at android.os.Handler.handleCallback(Handler.java:938)
2020-10-19 17:48:08.877 25964-25964/com.avis.mobile W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:99)
2020-10-19 17:48:08.877 25964-25964/com.avis.mobile W/System.err:     at android.os.Looper.loop(Looper.java:223)
2020-10-19 17:48:08.877 25964-25964/com.avis.mobile W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:7656)
2020-10-19 17:48:08.877 25964-25964/com.avis.mobile W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
2020-10-19 17:48:08.877 25964-25964/com.avis.mobile W/System.err:     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
2020-10-19 17:48:08.877 25964-25964/com.avis.mobile W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
![Screenshot_20201015-100400_Avis Car Hire](https://user-images.githubusercontent.com/62749617/96450858-62caf680-1234-11eb-8c20-627525730ccd.jpg)
![Screenshot_20201015-100400_Avis Car Hire](https://user-images.githubusercontent.com/62749617/96450927-79714d80-1234-11eb-8f9f-a77c4f16e2c7.jpg)

Even I tried with latest plugin also but it is not working. When I use Latest plugin and getting alert pop-up when device ready.

Expected behavior: Google map should work without any issue

Screen capture or video record:Screenshot_20201015-100400_Avis Car Hire

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


The person who share your project files on Github (or other git repository) is in faster lane than other people.
Please share your project files on Github or others(Bitbucket, Gitlabs...etc).
If you don't want to share your project files, please create a demo project, then share it.

Screen captures, and/or native logs(such as Logcat, xcode logs) are appreciate.

Giving much information, you are waiting time is less.
Thank you for your cooperation.
```https://guides.github.com/features/mastering-markdown/
wf9a5m75 commented 3 years ago

cordova-plugin-googlemaps 1.4.0 "

Out of support version

manivelponnusamy commented 3 years ago

Hi,

Even if I use latest google maps plugin also getting the same above error.

wf9a5m75 commented 3 years ago

v1 and v2 are completely different api.

wf9a5m75 commented 3 years ago

https://github.com/mapsplugin/cordova-plugin-googlemaps/blob/master/www/Environment.js#L12

wf9a5m75 commented 3 years ago

Please try to use this plugin in a new project, and only this plugin to confirm your problem. Even if it doesn't work, please share the project files on GitHub.

As you may know, this plugin is used by many developers.

manivelponnusamy commented 3 years ago

Hi,

I found the solution.

  1. ProGuard plugin is blocking the google map classes. So I have aded the below rule in proGuard rules. Now map is able to initialise.

#Google Maps Rules -keep class plugin.google.maps.** { *; }

  1. Again Map is not displaying and shows only white screen in both Android and iOS app. To display map again, we are calling map.setVisible(true) after set the Div to map object.
  2. When come back from map page, _gmaps_cdv_ class is not removing from body and other div in Android app. So When we call map.remove(), we removed the _gmaps_cdv_ css class from body and other div using JavaScript. Now it is working perfectly. We are using the below code for initiate the map.

map = plugin.google.maps.Map.getMap(); $timeout(function() { map.setDiv($element[0]); }, 1000);

I don't have any idea that why plugin is not removing `_gmapscdv' class properly when we go back from map page or when we call map.remove() method. One more thing, we are using directives to display maps, might be that is causing the issue, but. when we were using the older version of google maps plugin, we are not facing this issue.

wf9a5m75 commented 3 years ago

Thank you for your updates.

The biggest difference of v1 and v2 is that the position of the map view. In the v1, the map view is placed on <body>. Because of this, you can not put any HTML elements on the map, such as button, or you can not display a HTML dialog (such as modal).

In the v2, the map view is placed under the . It means behind the <body>. Because of this, you can put any HTML on the map, such as button, or display over the map, such as a dialog. But can you guess how the app can detect the touch is for HTML or Map?

WebView can not. Because WebView manages only <html>. MapView is out of <html>. Answer is this plugin. In v2, this plugin manages all position, size, hierarchy of (most of) all HTML elements. So, inside the v1 to v2, it becomes very complicated. That's why the maps plugin can not cover the some cases like your code.

Mohammad-Toufiq-Pathan commented 3 years ago

any update on this, didnt find any proper answer for this