DevConsole's public facade is a Kotlin object, but every method carries @JvmStatic and the async
variants carry @JvmOverloads. From Java it reads like an ordinary utility class, and you never
touch a coroutine: the ...Async variants take a callback instead.
-
Add the JitPack repository, then apply the production-safety plugin and split the dependency by variant (same
settings.gradle.kts/build.gradle.ktsshape as the Kotlin guide — see GETTING_STARTED_XML_KOTLIN.md steps 1–2). The two coordinates arecom.github.devconsole-android.DevConsole:devconsolefor debug andcom.github.devconsole-android.DevConsole:devconsole-noopfor release; there is no BOM. -
Add
INTERNETto your own app's manifest. The full debug runtime auto-mergesACCESS_LOCAL_NETWORK,NEARBY_WIFI_DEVICES,ACCESS_NETWORK_STATE, and the default foreground-service permissions; it does not mergeINTERNET— without it, the embedded server fails with an opaque socket error instead of a clear permission message:
<uses-permission android:name="android.permission.INTERNET" />- Add the optional launcher view to a debug-only layout:
<io.devconsole.ui.views.DevConsolePanelView
android:id="@+id/dev_console_panel"
android:layout_width="match_parent"
android:layout_height="wrap_content" />- Initialize, and use the
Asynccounterparts ofstartBrowser()/stop()since Java has no coroutines. The full debug runtime starts its foreground keep-alive service automatically whenstartBrowserAsync(...)succeeds. Pass it a callback and callpanel.setEndpoint(...)from it if you want the panel to show the bound address once it's known (DevConsoleState.Runningitself carries no payload, so this is the only way to get it):
DevConsole.initialize(getApplication(), DevConsoleConfig.builder()
// Optional: let the SDK open the in-app inspector on a shake or from a floating
// button. Both are off by default and never start the server.
.openTriggers(OpenTriggers.builder().shakeToOpen(true).floatingButton(true).build())
.build());
DevConsolePanelView panel = findViewById(R.id.dev_console_panel);
CoroutineScope panelScope = CoroutineScopeKt.CoroutineScope(Dispatchers.getMain());
panel.bind(
DevConsole.state(),
panelScope,
() -> {
DevConsole.startBrowserAsync(result -> {
if (result instanceof StartResult.Started) {
panel.setEndpoint(((StartResult.Started) result).getEndpoint());
}
});
return Unit.INSTANCE;
},
() -> { DevConsole.stopAsync(StopReason.UserRequested.INSTANCE); return Unit.INSTANCE; }
);- Push, mocks, network/socket capture, feature flags, and state providers all have plain
Java-constructible types (
PushInput,MockRule,NetworkRequestInput,FeatureFlag,DevConsoleConfig, ...) — none of them use Kotlin default arguments with@JvmOverloads, so every constructor parameter must be supplied explicitly from Java, and aStateProviderneeds an anonymous-class implementation rather than a lambda (it isn't a Kotlinfun interface). See the full working example — network + WebSocket capture, mocks, a manually-built push event, a Firebase-shaped push event run throughFirebaseRemoteMessageAdapterwith no real Firebase dependency, a feature flag, and a state provider — insamples/views-java-app.
See PUSH.md, COMPOSER_AND_MOCKS.md, and STATE_AND_FLAGS.md for what those calls do.