here-android-sdk-examples
here-android-sdk-examples copied to clipboard
Proper way to re-init mapEngine after failed
hi we found out that in certain brands devices, map engine gets failed to initialize easily after kill the app process and re-launch. I tried to re-init the mapEngine when i got init Error, but it seems that the map engine gets failed forever if it gets it once. (in my case the error states can't init twice) Is there any better way to re-init map engine while it inits fail?
Hi @bluesnow4425 Can you share device names? Which error do you get? We never bumped in that issue. What yo can try, to delete SDK cache (try to remove /sdcard/.here-maps folder). Also you can try to use MapSettings.setIsolatedDiskCacheRootPath() which allows to change SDK cache path.
Mostly if we use google phone, it happens more frequently. If we force to kill the app process, there's about 10-20% to crash. I use MapSettings.setIsolatedDiskCacheRootPath() in Application class which executes as soon as app launches.
What was the error code? Or can you share the crash log? We tried to reproduce on Google Pixel devices, but we could not.
@bluesnow4425 is there any updates?
i remembered it's an unknown error. I'll post the log in a day or two.
@bluesnow4425 please add more details like error.getDetails() and error.getStackTrace(). Thank you!
Most likely you are trying to init MapEngine/MapFragment in different threads. Try to synchronize this.
Unknown error occurred during engine init
i think this is details.
and I'm getting
java.lang.RuntimeException: Cannot initialize the engine twice
at com.nokia.maps.MapsEngine.<init>(MapsEngine.java:21)
at com.nokia.maps.MapsEngine.c(MapsEngine.java:9)
at com.nokia.maps.MapsEngine.a(MapsEngine.java:36)
at com.nokia.maps.MapsEngine.a(MapsEngine.java:24)
at com.here.android.mpa.common.MapEngine.init(MapEngine.java:1)
as stacktrace.
It says that the engine can't initialize twice, but first time fails and MapEngine.isInitialized() returns false either. Tried several ways but the only one works is to exit the app process and relaunchs again.
Ok, we never observed this issue, but from sources, it looks like initialization is done in at least two parallel threads. Other customers also do not report the issue. So it is difficult to reproduce. Can you remove business logic from your app and share with us? Or can you add minimal changes to the github sample in order to reproduce? Please share devices models as well.
https://github.com/bluesnow4425/here_map_init_research here's the repo. Tried and crash reproduce-able. I'm using google pixel 2 with latest android version.
Ok, I did not manage to get to the end of registration process =), but I saw few mapEngine/Fragment init() calls. That cause synchronization issue. As we are near the end of SDK 3.13 release, the fix can be included only in 3.14 release. As a workaround, synchronize all calls of MapEngine (Fragment calls MapEngine init method internally). For your case you can init Map on the application start (once), and the next calls (even simultaneous) should run w/o problems. Or add some pause before calling init() method second time.
thanks for feedback. Originally we call init only on the application start, but init failed issue happened, so we tried to init again and add another init to somewhere else. I'll try the process you suggested.
@bluesnow4425 What is the first error you got before running mapEngine init again? Please provide error code and details string (Error.getDetails).
@bluesnow4425 is there any updates? Could you please provide requested info? Or did you solve the issue?
We still facing init error sometimes, especially after the app crashes. We do Runtime.getRuntime().exit(0) to kill the whole process and relaunch the app again.
But was you able to get the init error? "What is the first error you got before running mapEngine init again?"
I think it's the same with my post above.
Does somebody resolved that issue? im still able to reproduce same error as above https://github.com/heremaps/here-android-sdk-examples/issues/384