Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map won't load #2900

Open
2 of 5 tasks
craig-at-rsg opened this issue Jan 26, 2022 · 18 comments
Open
2 of 5 tasks

Map won't load #2900

craig-at-rsg opened this issue Jan 26, 2022 · 18 comments

Comments

@craig-at-rsg
Copy link

craig-at-rsg commented Jan 26, 2022

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

@brian-duffy
Copy link

Also having this issue after upgrading to cordova 10.

@zimarron72
Copy link

Also having this issue. Any sugerency...

@uhmarc
Copy link

uhmarc commented May 1, 2022

I am also using Cordova 10 targeting 31 but for me it works. I wonder if this has to do with custom markers?

@Imranbadshahh
Copy link

I am also using Cordova 10 targeting 31 but does not for me it works .i can only see white screen and can u plz share me your sample code and when building did u get any issues regarding

@uhmarc
Copy link

uhmarc commented May 24, 2022

I am also using Cordova 10 targeting 31 but does not for me it works .i can only see white screen and can u plz share me your sample code and when building did u get any issues regarding

Will do. Give me a day or two. Currently traveling. Did you test it with an actual device? What Android version is the device?

But I did test it with the simulator as well on every Android version and it worked. What does the simulator do for you?

@Imranbadshahh
Copy link

Imranbadshahh commented May 25, 2022

I am also using Cordova 10 targeting 31 but does not for me it works .i can only see white screen and can u plz share me your sample code and when building did u get any issues regarding

Will do. Give me a day or two. Currently traveling. Did you test it with an actual device? What Android version is the device?

But I did test it with the simulator as well on every Android version and it worked. What does the simulator do for you?

Thanks for reply . I uninstalled the current one and installed this ionic cordova plugin add https://github.com/mapsplugin/cordova-plugin-googlemaps.git#0b8ea76ad34fb2a202a9de1b9d0e051a82ad9443

and also installed androidx and androidx-adapter and replace and imported some classes from androidX and androidX adapter that was not found in pluginMap.java file to fix build issue

and then everything worked fine for me Thanks :)

@keev-studio
Copy link

I also have this issue.
All works fine on android@9 but when change to android@10 the map do not load
any solution for this?

@davidaldan
Copy link

@keev-studio Do you solve your problem ??

@imrranbadshah
Copy link

I solved the issue by doing below steps

  1. Uninstall currently installed GoogleMaps Plugin and install using this command

npm i git+https://github.com/mapsplugin/cordova-plugin-googlemaps.git#0b8ea76ad34fb2a202a9de1b9d0e051a82ad9443

  1. install these 3 plugins

ionic cordova plugin add cordova-android-support-gradle-release --variable ANDROID_SUPPORT_VERSION=27.+
npm i cordova-plugin-android-support-v4
npm i cordova-plugin-androidx-adapter

  1. After step 2 goto Plugins Folder and inside
    Plugins-->cordova-plugin-googlemaps-->src-->android-->plugin-->google-->maps.
    inside this folder there will be many java files, among those files open below 2 files

PluginMap.java
PluginLocationService.java

and at the top import section search for PermissionChecker and NonNull and replace that 2 imports with this in both files

import android.support.annotation.NonNull;
import android.support.v4.content.PermissionChecker;

Finally remove and add the android platform again and run the projects

Note : in recent versions of ionic android platform there is androidX build in but still i suggest u to install using the above command .

@imrranbadshah
Copy link

imrranbadshah commented Aug 30, 2022

after doing this steps u can access the plugins by declaring
declare const window: any; below imports in ur app.component.ts file

For eg :
To set the google maps key u can do this

this.platform.ready().then(() => {
      window.plugin.google.maps.environment.setEnv({
        'API_KEY_FOR_BROWSER_RELEASE': '** YOUR MAPS KEY **',
        'API_KEY_FOR_BROWSER_DEBUG': ''** YOUR MAPS KEY **'  // optional
      });
 })

@lorenzodallavecchia
Copy link

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
Copy link

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.

Thanks Lorenzo for your input. Can you please elaborate more on specific changes you did to make the plugin working on Cordova 11. So many people waiting for this I suppose.
Thank you

lorenzodallavecchia added a commit to webratio/phonegap-plugin-googlemaps that referenced this issue Sep 7, 2022
The Maps plugin creates some helper CordovaPlugin objects and registers
them with PluginManager, and, at the same time, calls
'privateInitialize' manually. This causes an assertion to trip inside
Cordova Android.

The failing assertion only affects debug-mode builds that use a new
Android SDK. See also
mapsplugin#2900
@lorenzodallavecchia
Copy link

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

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.

@keev-studio
Copy link

keev-studio commented Oct 21, 2022

Hi, I am sorry it took me so long to implement your solution. Unfortunatelly the map stay blank (do not initialize loading) after using your fork.

@keev-studio
Copy link

@keev-studio Do you solve your problem ??

no, still looking for solution, did you find any?

@lorenzodallavecchia
Copy link

@keev-studio I guess the plugin is showing some other issue that I didn't encounter.
From what I have seen, an exception thrown in the wrong place will interfere with loading the map, and it would just stay blank.

Your best bet is to look at native Android logs. You can try opening your app in Android Studio and building from there, or may using the command adb logcat while you try opening the map.

@keev-studio
Copy link

keev-studio commented Oct 25, 2022

@keev-studio I guess the plugin is showing some other issue that I didn't encounter. From what I have seen, an exception thrown in the wrong place will interfere with loading the map, and it would just stay blank.

Your best bet is to look at native Android logs. You can try opening your app in Android Studio and building from there, or may using the command adb logcat while you try opening the map.

Hi, thank you for pushing me forward.
I am now checking the logcat, but apart of couple of warnings the app does not produce any meaningful errors. Not sure how I can proceed any further. Am I only one trying to run Googlemapss plugin in Cordova 11?
These are my errors:
Capture
Looks like the plugin do not even initialize the connection with Google server? Can this be some SSL issue?
These are my warnings
Capture

@nanaykubo
Copy link

Hello i've been solving this for hours already and i finally resolve the issue.

I solved the issue by doing below steps

  1. Uninstall currently installed GoogleMaps Plugin and install using this command

npm i git+https://github.com/mapsplugin/cordova-plugin-googlemaps.git#0b8ea76ad34fb2a202a9de1b9d0e051a82ad9443

  1. install these 3 plugins

ionic cordova plugin add cordova-android-support-gradle-release --variable ANDROID_SUPPORT_VERSION=27.+
npm i cordova-plugin-android-support-v4
npm i cordova-plugin-androidx-adapter

  1. After step 2 goto Plugins Folder and inside
    Plugins-->cordova-plugin-googlemaps-->src-->android-->plugin-->google-->maps.
    inside this folder there will be many java files, among those files open below 2 files

PluginMap.java
PluginLocationService.java

and at the top import section search for PermissionChecker and NonNull and replace that 2 imports with this in both files

import android.support.annotation.NonNull;
import android.support.v4.content.PermissionChecker;

Finally remove and add the android platform again and run the projects

Note : in recent versions of ionic android platform there is androidX build in but still i suggest u to install using the above command .

i've tried this and

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

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.

this also

mine is now working

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants