mapbox / mapbox/mapbox-maps-android

Crash when using custom httpservice client

Open
#2,055 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

auto-triaged bug :beetle:
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.