Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash when using custom httpservice client #2055

Open
SamYStudiO opened this issue Mar 22, 2023 · 1 comment
Open

Crash when using custom httpservice client #2055

SamYStudiO opened this issue Mar 22, 2023 · 1 comment
Labels
bug 🪲 Something isn't working

Comments

@SamYStudiO
Copy link

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

@SamYStudiO SamYStudiO added the bug 🪲 Something isn't working label Mar 22, 2023
@SamYStudiO SamYStudiO changed the title Crash when useing custom httpservice client Crash when using custom httpservice client Mar 23, 2023
@kalkun
Copy link

kalkun commented Aug 20, 2023

Im also experiencing this using SDK 10.15.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🪲 Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants