Public API, not engine internals
Cefrium is Chromium, so org.chromium.* is on the
classpath and reflection reaches it. Code that uses it breaks on the next
engine update, which every Cefrium release brings, and R8 cannot see
what reflection needs. Below is what apps reach in for, and the call that
does it instead. This guide covers 0.21.0.
Replacements
| Reaching for | Use |
|---|---|
Which renderer services the engine launches
(ChildProcessCreationParamsImpl, the command line) |
Cefrium.getRendererServices(): the service name, how many
the manifest declares, and whether they are the native ones of Android
17+. The service names are not API and have changed. |
| CSS or a script injected when the page finishes loading | addDocumentStartJavaScript(script, rules) runs before the
page's own scripts, in every matching document and iframe. Injected at
load end, cosmetic rules let ads show for a moment first. For CSS, adopt a
stylesheet from the script (see its reference). |
| Your own blocklist matched in a request interceptor | Cefrium.loadAdBlockList takes EasyList / uBlock syntax and
matches natively; CefriumProfile.setAdBlockExceptions turns it
off per site; Cefrium.loadYouTubeAdRules() adds the YouTube
rules, which since 0.16.0 no longer come with the first list. See
Ad blocking. |
| The page on top, tracked by hand in a request interceptor | Override RequestInterceptor.shouldBlockRequest(ResourceRequest)
(0.17.0): it gives the resource type, the document that made the request
and the page in the main frame. |
| Telling an iframe's bridge call from the page's | Override the QueryHandler.onQuery that takes
isMainFrame (0.17.0), or use
CefriumBridge.withFrames in Compose. Without
withSubframes() on the policy, iframes cannot call at all. |
| Saving a tab's history | serializeNavigationState() and
restoreNavigationState(bytes). |
| Page zoom | setZoomLevel;
setPinchToZoomEnabled for pinch. |
| Drawing selection handles in off-screen mode | CefriumRenderHandler.onTouchHandleChanged (0.17.0). See
Off-screen rendering. |
The DevTools protocol through the engine's own JNI
(GEN_JNI, DevToolsServer natives) |
executeDevToolsMethod(method, paramsJson, callback) and
setDevToolsEventListener (0.18.0): CDP in process, no
port. Cefrium.setRemoteDebuggingEnabled(true) lets
chrome://inspect attach over adb; leave it off in
release builds. |
| A script's return value | evaluateJavaScript(script, ValueCallback<String>)
(0.18.0) returns it as JSON, like
WebView.evaluateJavascript. |
| Mouse, key and touch input or a resize by reflection | They are public: sendMouseMove/Down/Up/Click/Wheel,
sendKeyEvent, sendTouchEvent,
setSize. Resize the browser, do not recreate it. See
Off-screen rendering. |
| A proxy per browser or profile (Tor, a VPN) | CefriumProfile.setProxy, with
setProxyErrorListener to learn the proxy is down. See
Network behaviour. |
R8
Keep R8 on. Since 0.12.0 the AAR's consumer rules keep what the engine needs and nothing more, and every release runs a minified app on a device before it ships. An app that turned R8 off "until Cefrium's reflection is verified" can turn it back on; if a class goes missing, that is a bug in our rules, so please report it.
Not public yet
These still need WebContents or a class placed in package
com.cefrium. Both break without notice. If you depend on one,
open an issue so it gets a public call:
- turning off double-tap zoom,
- your own items in the text-selection menu of an on-screen browser,
- renderer lifecycle beyond
onRenderProcessTerminated.