Huawei map seems to be initialized on second time

269 Views Asked by At

I do have an android app which is adjusted to be released at huawei store. Here is the initialization snippet:

if (areGoogleServicesAvailable()) {
      // google map here
} else {
      MapsInitializer.initialize(this)
      val mapFragment =
                supportFragmentManager.findFragmentById(R.id.mapHuawei) as com.huawei.hms.maps.SupportMapFragment
      mapFragment.getMapAsync {
          mapHuawei = it

          mapHuawei.update()
      }
}

This code runs in onCreate method of an activity. Now, if I open the activity for the first time since app being started, the map isn't shown, getMapAsync isn't triggered at all and in logs I can observe:

2023-05-15 12:32:00.429 11025-11025 HmsMapKit_...ragment_13 some.app              E  MapsInitializer is not initialized.

But starting from second time I open the activity, everything works as expected, getMapAsync is triggered and works further. Any ideas?

1

There are 1 best solutions below

0
nKognito On

Seems like moving MapsInitializer.initialize(this) to application.onCreate solves the issue