Skip to content

[FEATURE] Manual initialization support #229

@musilto7

Description

@musilto7

Summary

Please add support for manual initialization of DebugOverlay as an alternative to the automatic AndroidX Startup initializer.

Motivation

Our app has minSdk = 23. Since DebugOverlay requires a higher API level, we need to conditionally disable it on SDK 23 devices. Currently the only way to do this is to disable DebugOverlayStartupInitializer entirely in the manifest:

<provider
    android:name="androidx.startup.InitializationProvider"
    android:authorities="${applicationId}.androidx-startup"
    tools:node="merge">
    <meta-data
        android:name="com.ms.square.debugoverlay.DebugOverlayStartupInitializer"
        tools:node="remove" />
</provider>

But this disables DebugOverlay for all SDK versions, not just SDK 23.

Proposed API

Expose a public install() method so we can call it manually with an SDK version check:

class MyApplication : Application() {
    override fun onCreate() {
        super.onCreate()
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
            DebugOverlay.install(this)
            DebugOverlay.configure {
                  // configuration
            }
        }
    }
}

Current behavior

DebugOverlay.install() is marked @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) and @InternalDebugOverlayApi, making it inaccessible to app code. There is no supported way to manually initialize the library.

Expected behavior

A public install(application: Application) method that allows manual initialization, so developers can conditionally initialize DebugOverlay based on SDK version or any other runtime condition.

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions