Skip to content

feat: add RiveRuntime API for Android init failure handling - #153

Merged
mfazekas merged 6 commits into
mainfrom
feat/android-init-handling
Feb 27, 2026
Merged

mfazekas merged 6 commits into
mainfrom
feat/android-init-handling

Conversation

@mfazekas

@mfazekas mfazekas commented Feb 20, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Moves Rive.init() out of ContentProvider (which crashes before user code can run) into RivePackage.createViewManagers() with try/catch. Exposes RiveRuntime.initialize() and RiveRuntime.getStatus() to JS so apps can detect and recover from native lib loading failures (ABI mismatch, missing .so, etc).

Refs: rive-android#323, rive-android#341

Closes: #151

API

import { RiveRuntime } from '@rive-app/react-native';

const { isInitialized, error } = RiveRuntime.getStatus();
await RiveRuntime.initialize(); // manual init

To skip auto-init, set Rive_RiveRuntimeAndroidSkipSetup=true in gradle.properties.

Test plan

Tested with Rive_RiveRuntimeAndroidExcludeNativeLibs=true in our example. The code showed this:

image image

@mfazekas
mfazekas requested a review from HayesGordon February 20, 2026 19:23
@mfazekas
mfazekas force-pushed the feat/android-init-handling branch from 7bdc43e to d76a6b9 Compare February 20, 2026 19:23

}

// Exclude Rive native libs to emulate a native lib loading failure.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@HayesGordon HayesGordon left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thank you!

Move Rive.init() out of ContentProvider into RivePackage with try/catch.
Expose RiveRuntime.initialize() and RiveRuntime.getStatus() to JS so
apps can detect and recover from native lib loading failures.
… emulation

abiFilter restricts ALL native libs which crashes the entire app.
Use packagingOptions to exclude only librive-android.so so RN keeps
working and Rive.init() fails gracefully.
- Catch Throwable instead of Exception (UnsatisfiedLinkError is not an Exception)
- Throw RuntimeException instead of Error (fbjni only propagates Exception messages)
- Include exception class name in error for better debugging
Nitro's JNI bridge wraps Kotlin exceptions in jni::JniException which
loses the message in the C++ catch-all handler. Instead, manualInitialize()
now just sets the error status without throwing, and the JS wrapper reads
initError and throws a descriptive JS Error.
@mfazekas
mfazekas force-pushed the feat/android-init-handling branch from d76a6b9 to d8f28b8 Compare February 26, 2026 11:20
@mfazekas
mfazekas merged commit 634724e into main Feb 27, 2026
9 checks passed
@mfazekas
mfazekas deleted the feat/android-init-handling branch February 27, 2026 06:37
mfazekas pushed a commit that referenced this pull request Feb 27, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.2.4](v0.2.3...v0.2.4)
(2026-02-27)


### Features

* add RiveRuntime API for Android init failure handling
([#153](#153))
([634724e](634724e))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants