mapbox / mapbox/mapbox-maps-android
Crash when using custom httpservice client
Nobody has claimed this yet.
- Dominant language
- Kotlin
- Stars
- 578
- Forks
- 161
- PR merge metrics
- No merged PRs in 30d
Description
## Environment
- Android OS version: 33
- Devices affected: pixel 7
- Maps SDK Version: 10.12
## 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.
```
@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`
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the modularization guide and trace PlatformHttpService.createPlatformHttpService alongside Mapbox_HttpClientModuleConfiguration.moduleProvider initialization. Reproduce the startup crash using the CacheableTileHttpService example and verify that a configured CommonHttpClient provider is available before platform service creation without raising MapboxInvalidModuleException.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, kotlin
- Domain
- mobile, networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100