@MapboxModule(type = MapboxModuleType.CommonHttpClient, enableConfiguration = true)
class CacheableTileHttpService(private val tileProvidersRepository : TileProvidersRepository) : HttpServiceInterface {
...
}
class MainActivity : AppCompatActivity(){
override fun onCreate(savedInstanceState: Bundle?) {
Mapbox_HttpClientModuleConfiguration.moduleProvider =
object : Mapbox_HttpClientModuleConfiguration.ModuleProvider {
override fun createHttpClient(): HttpServiceInterface =
CacheableTileHttpService(viewModel.tileProvidersRepository)
}
super.onCreate(savedInstanceState)
...
}
this leads to crash MapboxInvalidModuleException(type=CommonHttpClient)
Seems PlatformHttpService.createPlatformHttpService is called before we get a chance to set moduleProvider, even setting moduleProvider from Application class will not get a chance to get called before PlatformHttpService.createPlatformHttpService
Environment
Observed behavior and steps to reproduce
Using guide to create custom http service module with
enableConfiguration
from https://github.com/mapbox/mapbox-base-android/blob/master/MODULARIZATION.md#dependency-injection leads to app crashing at startup.this leads to crash
MapboxInvalidModuleException(type=CommonHttpClient)
Seems
PlatformHttpService.createPlatformHttpService
is called before we get a chance to setmoduleProvider
, even settingmoduleProvider
from Application class will not get a chance to get called beforePlatformHttpService.createPlatformHttpService