### Low-Level Rendering Setup
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/rivefilecontroller.md
Example of setting up and using RiveFileController for custom rendering outside of RiveAnimationView. This involves manual creation, file assignment, and advancing/drawing within an animation loop.
```kotlin
// Create controller
val controller = RiveFileController()
controller.file = file
controller.activeArtboard = artboard
controller.isActive = true
// In animation loop
fun update(deltaTime: Float) {
artboard.advance(deltaTime)
stateMachine.advance(deltaTime)
}
fun render() {
artboard.draw(renderer.nativePointer)
}
```
--------------------------------
### Setting State Machine Inputs Based on User Input
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/smiinputs.md
Example of how to get state machine inputs and set their values based on user interactions like movement or button presses.
```kotlin
val stateMachine = artboard.firstStateMachine
// Get all inputs once
val inputs = stateMachine.inputs
// In your input handler
when {
isMovingRight -> {
val direction = stateMachine.input("direction") as SMINumber
direction.value = 1f
}
isMovingLeft -> {
val direction = stateMachine.input("direction") as SMINumber
direction.value = -1f
}
}
// Handle triggers
if (userPressedJump) {
val jumpTrigger = stateMachine.input("jump") as SMITrigger
jumpTrigger.fire()
}
```
--------------------------------
### RiveAnimationView XML Example
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/riveanimationview.md
This example demonstrates how to include RiveAnimationView in an XML layout, specifying the Rive resource, artboard, autoplay, fit, and alignment.
```xml
```
--------------------------------
### playingStateMachines
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/riveanimationview.md
Gets the set of currently playing state machine instances.
```APIDOC
## playingStateMachines
### Description
Gets the set of currently playing state machine instances.
### Property
`val playingStateMachines: HashSet`
**Type:** `HashSet` (read-only)
```
--------------------------------
### Data Binding Integration Example
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/viewmodel.md
Shows how to set up data binding between a ViewModel instance and an artboard, and update properties during the app lifecycle.
```kotlin
// Set up data binding
val artboard = file.createDefaultBindableArtboard()
val instance = viewModel.createDefaultInstance()
artboard.receiveViewModelInstance(instance.transfer())
// During app lifecycle, update properties
fun onUserDataChanged(userData: UserData) {
instance.setProperty("name", userData.name)
instance.setProperty("score", userData.score.toFloat())
}
```
--------------------------------
### Basic Animation Playback Setup and Loop
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/linearanimationinstance.md
Demonstrates setting up an animation with looping and a default mix, then advancing and applying it within a game loop.
```kotlin
val artboard = file.firstArtboard
val animation = artboard.animation("Idle")
// Setup
animation.loop = Loop.LOOP
animation.mix = 1.0f
// Game loop
fun update(deltaTime: Float) {
val result = animation.advanceAndGetResult(deltaTime)
animation.apply()
when (result) {
AdvanceResult.LOOP -> println("Loop occurred")
AdvanceResult.ONESHOT -> animation.time(0f) // Restart
else -> {}
}
}
```
--------------------------------
### Full ViewModel Usage Pattern
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/viewmodel.md
Demonstrates loading a file, getting a ViewModel, creating and configuring an instance, and assigning it to an artboard or state machine.
```kotlin
// Load file
val bytes = resources.openRawResource(R.raw.animation).readBytes()
val file = File(bytes)
// Get ViewModel definition
val viewModel = file.getViewModelByName("UserData")
// Create and configure instance
val instance = viewModel.createBlankInstance()
instance.setProperty("username", "Player1")
instance.setProperty("score", 1000f)
instance.setProperty("isPremium", true)
// Get bindable artboard and assign instance
val transfer = instance.transfer()
val artboard = file.createDefaultBindableArtboard()
artboard.receiveViewModelInstance(transfer)
// Or with state machine
val stateMachine = artboard.firstStateMachine
stateMachine.viewModelInstance = instance
// Update properties at runtime
instance.setProperty("score", 2000f)
instance.setProperty("isPremium", false)
// Verify changes
val currentScore = instance.getProperty("score")
println("Score: $currentScore")
```
--------------------------------
### fit
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/rivefilecontroller.md
Gets or sets how artboards are fitted to available space.
```APIDOC
## fit
### Description
How artboards are fitted to available space.
### Type
`Fit` (read-write)
### Default
`Fit.CONTAIN`
### Example
```kotlin
controller.fit = Fit.CONTAIN
```
```
--------------------------------
### play()
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/riveanimationview.md
Starts playing animations or state machines. Supports playing all animations, by specific name, or multiple animations.
```APIDOC
## play()
### Description
Starts playing animations or state machines. This method has multiple overloads to control playback.
### Method
`play()`
### Overloads
**1. Play All/Default:**
```kotlin
fun play(
loop: Loop = Loop.AUTO,
direction: Direction = Direction.AUTO,
settleInitialState: Boolean = true
)
```
**Parameters:**
- **loop** (`Loop`) - Optional - Loop behavior. Defaults to `Loop.AUTO`.
- **direction** (`Direction`) - Optional - Play direction. Defaults to `Direction.AUTO`.
- **settleInitialState** (`Boolean`) - Optional - Settle state machine state on init. Defaults to `true`.
**Example:**
```kotlin
riveView.play()
riveView.play(loop = Loop.LOOP, direction = Direction.FORWARDS)
```
**2. Play by Name:**
```kotlin
fun play(
animationName: String,
loop: Loop = Loop.AUTO,
direction: Direction = Direction.AUTO,
isStateMachine: Boolean = false,
settleInitialState: Boolean = true
)
```
**Parameters:**
- **animationName** (`String`) - Required - Animation or state machine name.
- **loop** (`Loop`) - Optional - Loop behavior. Defaults to `Loop.AUTO`.
- **direction** (`Direction`) - Optional - Play direction. Defaults to `Direction.AUTO`.
- **isStateMachine** (`Boolean`) - Optional - Whether this is a state machine. Defaults to `false`.
- **settleInitialState** (`Boolean`) - Optional - Settle SM state on init. Defaults to `true`.
**Example:**
```kotlin
riveView.play("Idle", isStateMachine = true)
```
**3. Play Multiple:**
```kotlin
fun play(
animationNames: List,
loop: Loop = Loop.AUTO,
direction: Direction = Direction.AUTO,
areStateMachines: Boolean = false,
settleInitialState: Boolean = true
)
```
**Parameters:**
- **animationNames** (`List`) - Required - List of animation or state machine names.
- **loop** (`Loop`) - Optional - Loop behavior. Defaults to `Loop.AUTO`.
- **direction** (`Direction`) - Optional - Play direction. Defaults to `Direction.AUTO`.
- **areStateMachines** (`Boolean`) - Optional - Whether these are state machines. Defaults to `false`.
- **settleInitialState** (`Boolean`) - Optional - Settle SM state on init. Defaults to `true`.
**Example:**
```kotlin
riveView.play(listOf("Walk", "Run"), loop = Loop.LOOP)
```
```
--------------------------------
### file
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/riveanimationview.md
Gets the currently loaded Rive file.
```APIDOC
## file
### Description
Gets the currently loaded Rive file.
### Property
`val file: File?`
**Type:** `File?` (read-only)
**Example:**
```kotlin
val file = riveView.file
val artboardCount = file?.artboardCount ?: 0
```
```
--------------------------------
### stateMachines
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/riveanimationview.md
Gets a list of all state machine instances in the current artboard.
```APIDOC
## stateMachines
### Description
Gets a list of all state machine instances in the current artboard.
### Property
`val stateMachines: List`
**Type:** `List` (read-only)
**Example:**
```kotlin
riveView.stateMachines.forEach { sm ->
println("State Machine: ${sm.name}")
}
```
```
--------------------------------
### Record Perfetto Trace on Device
Source: https://github.com/rive-app/rive-android/blob/master/tools/perfetto/README.md
Execute this command on the device to start recording a Perfetto trace using the specified configuration file. The trace will be saved to the device.
```bash
adb shell perfetto -c /data/local/tmp/rive-trace.textproto -o /data/misc/perfetto-traces/rive-trace.pftrace
```
--------------------------------
### Handle ArtboardException by Name
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/errors.md
Example of catching an ArtboardException when attempting to access an artboard by a name that does not exist.
```kotlin
try {
val artboard = file.artboard("NonExistent")
} catch (e: ArtboardException) {
println("Artboard not found: ${e.message}")
// Message: Artboard "NonExistent" not found. Available Artboards: ["Main", "UI"]
}
```
--------------------------------
### Play All Animations
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/riveanimationview.md
Starts playing all animations on the RiveView. Supports custom loop and direction settings.
```kotlin
riveView.play()
riveView.play(loop = Loop.LOOP, direction = Direction.FORWARDS)
```
--------------------------------
### Handling Rive Events
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/README.md
Provides an example of how to listen for and handle Rive events, such as opening URLs or triggering custom game logic based on event names and properties.
```kotlin
riveView.addListener(object : RiveFileController.Listener {
override fun onRiveEventReceived(event: RiveEvent) {
when (event) {
is RiveOpenURLEvent -> {
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(event.url))
startActivity(intent)
}
is RiveGeneralEvent -> {
when (event.name) {
"levelComplete" -> showLevelComplete()
"bonus" -> awardBonus(event.properties)
}
}
}
}
})
```
--------------------------------
### activeArtboard
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/rivefilecontroller.md
Gets or sets the currently active artboard.
```APIDOC
## activeArtboard
### Description
The currently active artboard.
### Type
`Artboard?` (read-write)
### Example
```kotlin
controller.activeArtboard = artboard
```
```
--------------------------------
### Handle ArtboardException by Index
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/errors.md
Example of catching an ArtboardException when attempting to access an artboard by an index that is out of bounds.
```kotlin
try {
val artboard = file.artboard(99)
} catch (e: ArtboardException) {
println("Index error: ${e.message}")
// Message: No Artboard found at index 99.
}
```
--------------------------------
### State Machine Usage Pattern
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/statemachineinstance.md
Demonstrates a typical usage pattern for a Rive state machine, including setup, input management, advancing the state machine and artboard, and rendering.
```kotlin
val artboard = file.firstArtboard
val stateMachine = artboard.stateMachine("Controls")
// Setup inputs
val speedInput = stateMachine.input("speed") as SMINumber
val jumpTrigger = stateMachine.input("jump") as SMITrigger
// Game loop
fun update(deltaTime: Float) {
// Update input based on user action
speedInput.value = userSpeed
// Check for jump action
if (userJumpPressed) {
jumpTrigger.fire()
}
// Advance state machine
stateMachine.advance(deltaTime)
// Apply changes to artboard
artboard.advance(deltaTime)
}
// Drawing
fun render() {
artboard.draw(renderer.nativePointer)
}
```
--------------------------------
### RiveFileController Constructor
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/rivefilecontroller.md
Initializes a RiveFileController with optional loop mode, autoplay setting, initial file, active artboard, and a start callback.
```kotlin
class RiveFileController(
var loop: Loop = Loop.AUTO,
var autoplay: Boolean = true,
file: File? = null,
activeArtboard: Artboard? = null,
var onStart: OnStartCallback? = null
)
```
--------------------------------
### Handle StateMachineInputException by Index
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/errors.md
Example of catching a StateMachineInputException when an input is not found at a specified index.
```kotlin
try {
val input = stateMachine.input(5) // Only 3 inputs exist
} catch (e: StateMachineInputException) {
println("Input not found: ${e.message}")
// Message: No StateMachineInput found at index 5.
}
```
--------------------------------
### name
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/artboard.md
Gets the name of the artboard as defined in the Rive editor.
```APIDOC
## name
### Description
The name of the artboard.
### Property Signature
```kotlin
val name: String
```
### Type
`String` (read-only)
### Example
```kotlin
println("Artboard: ${artboard.name}")
```
```
--------------------------------
### file
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/rivefilecontroller.md
Gets or sets the loaded Rive file. Setting a new file releases the old one.
```APIDOC
## file
### Description
The loaded Rive file.
### Type
`File?` (read-write)
### Notes
Setting a new file releases the old one. Automatically acquires references.
### Example
```kotlin
controller.file = newFile
```
```
--------------------------------
### Reference Counting Example
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/README.md
Demonstrates the reference counting mechanism for File and BindableArtboard objects. Ensure you release objects when they are no longer needed to prevent memory leaks.
```kotlin
val file = File(bytes) // refs = 1
// When assigned to RiveAnimationView, refs incremented
riveView.file = file // refs = 2
// Must release when done
file.release() // refs = 1
// refs = 0 when RiveAnimationView releases it
```
--------------------------------
### Get First Artboard
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/file.md
Accesses the first artboard in the file. This is useful when a file is expected to contain only one artboard.
```kotlin
val artboard = file.firstArtboard
```
--------------------------------
### stateMachineNames
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/artboard.md
Gets a list of names for all state machines present in the artboard.
```APIDOC
## stateMachineNames
### Description
Names of all state machines in the artboard.
### Property Signature
```kotlin
val stateMachineNames: List
```
### Type
`List` (read-only)
```
--------------------------------
### alignment
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/rivefilecontroller.md
Gets or sets how artboards are aligned within the fitted space.
```APIDOC
## alignment
### Description
How artboards are aligned within fitted space.
### Type
`Alignment` (read-write)
### Default
`Alignment.CENTER`
### Example
```kotlin
controller.alignment = Alignment.CENTER
```
```
--------------------------------
### Handle StateMachineException for No State Machines
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/errors.md
Example of catching a StateMachineException when attempting to access the first state machine of an artboard that has none.
```kotlin
try {
val sm = artboard.firstStateMachine // No state machines exist
} catch (e: StateMachineException) {
println("Error: ${e.message}")
}
```
--------------------------------
### Handle AnimationException for No Animations
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/errors.md
Example of catching an AnimationException when trying to access the first animation of an artboard that has no animations.
```kotlin
try {
val animation = artboard.firstAnimation // No animations exist
} catch (e: AnimationException) {
println("No animations: ${e.message}")
}
```
--------------------------------
### Get State Machine by Index
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/artboard.md
Retrieves a StateMachineInstance by its zero-based index. Use this to control state machine transitions.
```kotlin
val sm = artboard.stateMachine(0)
```
--------------------------------
### Get Animation Work Start Frame
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/linearanimationinstance.md
Retrieves the start frame of the animation's work area. Returns -1 if no work start is set.
```kotlin
val workStart: Int
```
```kotlin
val startFrame = animation.workStart
if (startFrame != -1) {
// Work area is defined
}
```
--------------------------------
### workStart
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/linearanimationinstance.md
Gets the start frame of the animation's work area. Returns -1 if no work start is set.
```APIDOC
## workStart
### Description
Start frame of the animation's work area.
### Type
`Int` (read-only)
### Notes
Returns -1 if no work start is set
### Example
```kotlin
val startFrame = animation.workStart
if (startFrame != -1) {
// Work area is defined
}
```
```
--------------------------------
### Get State Machine Names
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/artboard.md
Retrieves a list containing the names of all state machines within the artboard.
```kotlin
val stateMachineNames: List
```
--------------------------------
### effectiveDuration
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/linearanimationinstance.md
Gets the duration of the animation in frames, accounting for any set work start and end markers. If no markers are set, this equals the total duration.
```APIDOC
## effectiveDuration
### Description
Gets the duration of the animation in frames, accounting for any set work start and end markers. If no markers are set, this equals the total duration.
### Property
`val effectiveDuration: Int`
### Type
`Int` (read-only)
### Notes
If no work markers are set, equals `duration`
### Example
```kotlin
val workFrames = animation.effectiveDuration
```
```
--------------------------------
### Monitoring State Machine State
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/smiinputs.md
Examples of how to read the current values of boolean and numeric inputs to monitor the state machine's condition.
```kotlin
// Check if animation is enabled
val enabled = stateMachine.input("enabled") as SMIBoolean
if (enabled.value) {
println("Animation is enabled")
}
// Check current parameter value
val speed = stateMachine.input("speed") as SMINumber
println("Current speed: ${speed.value}")
```
--------------------------------
### width
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/artboard.md
Gets or sets the width of the artboard. This allows dynamic resizing of the artboard's display area.
```APIDOC
## width
### Description
The width of the artboard.
### Property Signature
```kotlin
var width: Float
```
### Type
`Float` (read-write)
### Example
```kotlin
artboard.width = 800f
```
```
--------------------------------
### Constructor
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/rivefilecontroller.md
Initializes a new RiveFileController with specified playback settings and optional initial file or artboard.
```APIDOC
## Constructor RiveFileController
### Description
Initializes a new RiveFileController.
### Parameters
#### Path Parameters
* **loop** (`Loop`) - Optional - Default `Loop.AUTO` - Default loop mode for animations.
* **autoplay** (`Boolean`) - Optional - Default `true` - Auto-play animations when loaded.
* **file** (`File?`) - Optional - Default `null` - Initial Rive file.
* **activeArtboard** (`Artboard?`) - Optional - Default `null` - Initial artboard.
* **onStart** (`OnStartCallback?`) - Optional - Default `null` - Callback when ready.
```
--------------------------------
### Run Test Suite with Gradle
Source: https://github.com/rive-app/rive-android/blob/master/CONTRIBUTING.md
Execute the test suite from the project root using Gradle.
```shell
./gradlew
```
--------------------------------
### Get Effective Animation Duration in Frames
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/linearanimationinstance.md
Retrieves the animation's duration in frames, taking into account any set work start and end markers. If no markers are set, this equals the total duration.
```kotlin
val workFrames = animation.effectiveDuration
```
--------------------------------
### Get First State Machine Instance
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/artboard.md
Accesses the first state machine associated with this artboard. Throws a StateMachineException if no state machines exist.
```kotlin
val firstStateMachine: StateMachineInstance
```
--------------------------------
### name
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/linearanimationinstance.md
Gets the name of the animation.
```APIDOC
## name
### Description
Gets the name of the animation.
### Property
`override val name: String`
### Type
`String` (read-only)
### Example
```kotlin
println("Playing: ${animation.name}")
```
```
--------------------------------
### artboardName
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/riveanimationview.md
Gets or sets the active artboard name.
```APIDOC
## artboardName
### Description
Gets or sets the active artboard name.
### Property
`var artboardName: String?`
**Type:** `String?` (read-write)
**Example:**
```kotlin
riveView.artboardName = "UI"
println("Current artboard: ${riveView.artboardName}")
```
```
--------------------------------
### Initialize File with Specific Renderer
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/configuration.md
Specify the rendering backend for a particular Rive file during initialization.
```kotlin
val file = File(
bytes = bytes,
rendererType = RendererType.Canvas,
fileAssetLoader = null
)
```
--------------------------------
### Get Artboard by Index
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/file.md
Retrieve an artboard from the loaded file using its zero-based index. Ensure the index is within the valid range of artboards.
```kotlin
val firstArtboard = file.artboard(0)
```
--------------------------------
### Get State Machine by Index
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/artboard.md
Retrieves a StateMachineInstance by its zero-based index. This is useful for accessing state machines when their order is known.
```APIDOC
## stateMachine (index)
### Description
Get a state machine instance by its index.
### Method
`fun stateMachine(index: Int): StateMachineInstance`
### Parameters
#### Path Parameters
- **index** (Int) - Required - Zero-based state machine index
### Response
#### Success Response
- **StateMachineInstance** — State machine controller
### Throws
- **StateMachineException** — if index out of bounds
### Example
```kotlin
val sm = artboard.stateMachine(0)
```
```
--------------------------------
### Build Native Libraries and Update NDK Path
Source: https://github.com/rive-app/rive-android/blob/master/CONTRIBUTING.md
Steps to build the native .so files for different architectures. This involves navigating to the cpp directory, setting the NDK_PATH environment variable, and rebuilding the project.
```shell
cd kotlin/src/main/cpp/
# Add NDK_PATH variable to your .zshenv
NDK_VERSION=$(tr <.ndk_version -d " \t\n\r")
echo 'export NDK_PATH=~/Library/Android/sdk/ndk/${NDK_VERSION}' >> ~/.zshenv
source ~/.zshenv
# Back to the top of the repo
cd -
# Make sure everything still builds
./gradlew assembleDebug
# After the script above completes successfully, commit your changes
git add .
```
--------------------------------
### Get State Machine by Name
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/artboard.md
Retrieves a StateMachineInstance by its name. This allows for easy access to state machines using their defined names.
```APIDOC
## stateMachine (name)
### Description
Get a state machine instance by its name.
### Method
`fun stateMachine(name: String): StateMachineInstance`
### Parameters
#### Path Parameters
- **name** (String) - Required - State machine name
### Response
#### Success Response
- **StateMachineInstance** — State machine controller
### Throws
- **StateMachineException** — if not found
### Example
```kotlin
val sm = artboard.stateMachine("Controls")
```
```
--------------------------------
### Get Artboard Names
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/file.md
Retrieves a list of names for all artboards contained within the file. Useful for identifying or selecting artboards by name.
```kotlin
val artboardNames = file.artboardNames
println("Available artboards: $names")
```
--------------------------------
### playingAnimations
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/riveanimationview.md
Gets the set of currently playing animation instances.
```APIDOC
## playingAnimations
### Description
Gets the set of currently playing animation instances.
### Property
`val playingAnimations: HashSet`
**Type:** `HashSet` (read-only)
```
--------------------------------
### Iterate Through File Enums
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/types.md
Example of iterating through the enums defined in a Rive file. This snippet shows how to access the name and values of each enum.
```kotlin
file.enums.forEach { enum ->
println("${enum.name}: ${enum.values}")
// Output: "Season: [spring, summer, fall, winter]"
}
```
--------------------------------
### Calculate Rectangle Dimensions
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/types.md
Example of calculating the width and height of a rectangle using its bounds. This snippet demonstrates accessing the left, top, right, and bottom properties of a RectF.
```kotlin
val bounds = artboard.bounds
val width = bounds.right - bounds.left
val height = bounds.bottom - bounds.top
```
--------------------------------
### animations
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/riveanimationview.md
Gets a list of all animation instances in the current artboard.
```APIDOC
## animations
### Description
Gets a list of all animation instances in the current artboard.
### Property
`val animations: List`
**Type:** `List` (read-only)
**Example:**
```kotlin
riveView.animations.forEach { anim ->
println("Animation: ${anim.name}")
}
```
```
--------------------------------
### Rive Event Handling Pattern in Android
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/riveevent.md
Example of adding a listener to RiveAnimationView to receive and handle Rive events in an Android Activity.
```kotlin
class MyActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val riveView = findViewById(R.id.rive_view)
// Add event listener
riveView.addListener(object : RiveFileController.Listener {
override fun onFileLoaded(file: File) {
println("File loaded: ${file.artboardNames}")
}
override fun onRiveEventReceived(riveEvent: RiveEvent) {
when (riveEvent) {
is RiveOpenURLEvent -> {
// Open URL
val intent = Intent(Intent.ACTION_VIEW)
intent.data = Uri.parse(riveEvent.url)
startActivity(intent)
}
is RiveGeneralEvent -> {
// Handle custom event
when (riveEvent.name) {
"levelComplete" -> handleLevelComplete()
"showDialog" -> {
val message = riveEvent.properties["message"] as? String
showDialog(message)
}
}
}
else -> {
// Handle other event types
println("Event: ${riveEvent.name}")
}
}
}
})
}
}
```
--------------------------------
### Get Artboard by Name
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/file.md
Retrieve an artboard from the loaded file using its name. Ensure the artboard name exists in the Rive editor.
```kotlin
val artboard = file.artboard("Main")
```
--------------------------------
### Build Debug Bundle with Gradle
Source: https://github.com/rive-app/rive-android/blob/master/CONTRIBUTING.md
Run this command from the project root to build a debug bundle of the application.
```shell
./gradlew :app:bundleDebug
```
--------------------------------
### autoplay
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/riveanimationview.md
Gets or sets whether animations should play automatically.
```APIDOC
## autoplay
### Description
Gets or sets whether animations should play automatically.
### Property
`var autoplay: Boolean`
**Type:** `Boolean` (read-write)
**Example:**
```kotlin
riveView.autoplay = false
```
```
--------------------------------
### Handle Event Type
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/types.md
Example of checking the type of an event received from a state machine. This snippet demonstrates how to perform actions based on specific event types.
```kotlin
when (event.type) {
EventType.OpenURLEvent -> {}
EventType.GeneralEvent -> {}
}
```
--------------------------------
### animationNames
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/artboard.md
Gets a list of names for all animations present in the artboard.
```APIDOC
## animationNames
### Description
Names of all animations in the artboard.
### Property Signature
```kotlin
val animationNames: List
```
### Type
`List` (read-only)
```
--------------------------------
### Rive.initializeCppEnvironment
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/rive.md
Manually initializes the JNI bindings after native libraries have been loaded independently. This is typically used in advanced scenarios like split APK delivery.
```APIDOC
## Rive.initializeCppEnvironment
### Description
Manually initializes the JNI bindings after loading native libraries independently.
### Method
```kotlin
@JvmStatic
fun initializeCppEnvironment()
```
### Parameters
None
### Notes
Only call this if you manually load the native libraries with `System.loadLibrary()` before initializing Rive. This is useful for split APK/dynamic feature delivery scenarios where libraries are loaded from a split context.
### Example
```kotlin
System.loadLibrary("c++_shared")
System.loadLibrary("rive-android")
Rive.initializeCppEnvironment()
```
```
--------------------------------
### Instantiate File with Release
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/file.md
Instantiate a File object from raw bytes and ensure it's released to prevent memory leaks. This is crucial for managing native resources.
```kotlin
val bytes = resources.openRawResource(R.raw.animation).readBytes()
val file = File(bytes)
try {
val artboard = file.firstArtboard
// Use artboard...
} finally {
file.release()
}
```
--------------------------------
### Handle Animation Advance Result
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/types.md
Example of how to handle the AdvanceResult returned by `advanceAndGetResult`. This snippet shows conditional logic based on the animation's outcome.
```kotlin
when (animation.advanceAndGetResult(deltaTime)) {
AdvanceResult.LOOP -> println("Animation looped")
AdvanceResult.ONESHOT -> println("Animation finished")
else -> {}
}
```
--------------------------------
### Usage Patterns
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/smiinputs.md
Illustrates common patterns for setting and monitoring state machine inputs.
```APIDOC
## Usage Patterns
### Setting Inputs Based on User Input
```kotlin
val stateMachine = artboard.firstStateMachine
// Get all inputs once
val inputs = stateMachine.inputs
// In your input handler
when {
isMovingRight -> {
val direction = stateMachine.input("direction") as SMINumber
direction.value = 1f
}
isMovingLeft -> {
val direction = stateMachine.input("direction") as SMINumber
direction.value = -1f
}
}
// Handle triggers
if (userPressedJump) {
val jumpTrigger = stateMachine.input("jump") as SMITrigger
jumpTrigger.fire()
}
```
### Monitoring State Machine State
```kotlin
// Check if animation is enabled
val enabled = stateMachine.input("enabled") as SMIBoolean
if (enabled.value) {
println("Animation is enabled")
}
// Check current parameter value
val speed = stateMachine.input("speed") as SMINumber
println("Current speed: ${speed.value}")
```
### Chaining Multiple Inputs
```kotlin
val walkSpeed = stateMachine.input("walkSpeed") as SMINumber
val isRunning = stateMachine.input("isRunning") as SMIBoolean
walkSpeed.value = if (isRunning.value) 200f else 50f
```
```
--------------------------------
### Create Default Bindable Artboard
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/file.md
Create a BindableArtboard from the file's default artboard, suitable for data binding. This instance also requires manual release.
```kotlin
val artboard = file.createDefaultBindableArtboard()
```
--------------------------------
### Initialize Rive with Default Renderer
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/configuration.md
Select the default rendering backend for Rive at initialization. GPU-accelerated rendering is used by default.
```kotlin
// GPU-accelerated (default)
Rive.init(context, defaultRenderer = RendererType.Rive)
// Software fallback
Rive.init(context, defaultRenderer = RendererType.Canvas)
```
--------------------------------
### Handle ViewModel Property Type
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/types.md
Example of checking the data type of a ViewModel property. This snippet uses a when expression to handle different property types.
```kotlin
val prop = viewModel.properties.first()
when (prop.type) {
ViewModel.PropertyDataType.STRING -> {}
ViewModel.PropertyDataType.NUMBER -> {}
else -> {}
}
```
--------------------------------
### animationCount
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/artboard.md
Gets the total number of animations available within this artboard.
```APIDOC
## animationCount
### Description
Number of animations in the artboard.
### Property Signature
```kotlin
val animationCount: Int
```
### Type
`Int` (read-only)
### Example
```kotlin
for (i in 0 until artboard.animationCount) {
val anim = artboard.animation(i)
}
```
```
--------------------------------
### Handle Cannot Create Instance Exception
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/errors.md
Catches and logs an exception when creating a default ViewModel instance fails.
```kotlin
try {
val instance = viewModel.createDefaultInstance()
} catch (e: ViewModelException) {
println("Cannot create instance: ${e.message}")
// Message: Could not create default ViewModel instance
}
```
--------------------------------
### Configure RiveAnimationView Programmatically
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/configuration.md
Configures a RiveAnimationView using a Builder pattern in Kotlin code. This allows for dynamic setup of animation properties, fit, alignment, and other behaviors at runtime.
```kotlin
val riveView = RiveAnimationView.Builder(context)
.setResource(R.raw.animation)
.setArtboardName("Main")
.setAnimationName("Idle")
.setFit(Fit.CONTAIN)
.setAlignment(Alignment.CENTER)
.setLoop(Loop.LOOP)
.setRendererType(RendererType.Rive)
.setAutoplay(true)
.setAutoBind(false)
.setTraceAnimations(false)
.setTouchPassThrough(false)
.setMultiTouchEnabled(false)
.setShouldLoadCDNAssets(true)
.setAssetLoader(customLoader)
.build()
parent.addView(riveView)
```
--------------------------------
### fps
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/linearanimationinstance.md
Gets the frames per second (FPS) configured for this animation.
```APIDOC
## fps
### Description
Gets the frames per second (FPS) configured for this animation.
### Property
`val fps: Int`
### Type
`Int` (read-only)
### Example
```kotlin
val frameRate = animation.fps
println("Animation FPS: $frameRate")
```
```
--------------------------------
### File Constructor
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/file.md
Constructs a new File instance from raw .riv file bytes. It can optionally take a custom renderer type and an asset loader for external resources. Remember to call `release()` on the File instance when it's no longer needed to prevent memory leaks.
```APIDOC
## File Constructor
### Description
Initializes a new `File` object from a byte array representing a Rive file. Allows specifying a custom renderer and an optional asset loader for external resources like images, fonts, and audio. It's crucial to call the `release()` method on the created `File` instance to free up native memory and prevent leaks.
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
None
### Parameters
- **bytes** (`ByteArray`) - Required - The raw bytes of the .riv file.
- **rendererType** (`RendererType`) - Optional - Defaults to `Rive.defaultRendererType`. The renderer to use for the file's contents.
- **fileAssetLoader** (`FileAssetLoader?`) - Optional - Defaults to `null`. An optional asset loader for external resources (images, fonts, audio).
### Throws
- `RiveException` — if the file bytes are invalid or in an unsupported format.
### Example
```kotlin
val bytes = resources.openRawResource(R.raw.animation).readBytes()
val file = File(bytes)
try {
val artboard = file.firstArtboard
// Use artboard...
} finally {
file.release()
}
```
```
--------------------------------
### time (property)
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/linearanimationinstance.md
Gets the current playback time of the animation in seconds.
```APIDOC
## time (property)
### Description
Gets the current playback time of the animation in seconds.
### Property
`val time: Float`
### Type
`Float` (read-only)
### Unit
Seconds
### Example
```kotlin
val currentTime = animation.time
```
```
--------------------------------
### Custom Rendering Loop
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/README.md
Illustrates how to implement a custom rendering loop for Rive animations, allowing for manual control over animation advancement and drawing on the OpenGL thread.
```kotlin
val controller = RiveFileController()
controller.file = file
controller.activeArtboard = artboard
controller.isActive = true
// Animation loop (on rendering thread)
fun render() {
artboard.advance(frameTime)
artboard.draw(renderer.nativePointer)
}
```
--------------------------------
### stateMachineCount
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/artboard.md
Gets the total number of state machines available within this artboard.
```APIDOC
## stateMachineCount
### Description
Number of state machines in the artboard.
### Property Signature
```kotlin
val stateMachineCount: Int
```
### Type
`Int` (read-only)
```
--------------------------------
### Basic CMake Configuration
Source: https://github.com/rive-app/rive-android/blob/master/kotlin/src/main/cpp/CMakeLists.txt
Sets the minimum CMake version, project name, and version. It also enables exporting compile commands and verbose Makefiles.
```cmake
cmake_minimum_required(VERSION 3.18.1)
project(rive-android VERSION 1.0.0 LANGUAGES CXX)
# Compile detail will be in rive-android/kotlin/.cxx/Debug///compile_commands.json
# e.g: kotlin/.cxx/Debug/4o1b5h48/arm64-v8a/compile_commands.json
set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE INTERNAL "")
set(CMAKE_VERBOSE_MAKEFILE ON)
```
--------------------------------
### Get Artboard Name
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/artboard.md
Retrieves the name of the artboard as defined in the Rive editor.
```kotlin
val name: String
```
```kotlin
println("Artboard: ${artboard.name}")
```
--------------------------------
### direction
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/linearanimationinstance.md
Gets or sets the playback direction of the animation. Can be forwards, backwards, or automatic.
```APIDOC
## direction
### Description
Gets or sets the playback direction of the animation. Can be forwards, backwards, or automatic.
### Property
`var direction: Direction`
### Type
`Direction` (read-write)
### Values
- `Direction.FORWARDS` — Play forward
- `Direction.BACKWARDS` — Play backward
- `Direction.AUTO` — Automatic based on state machine
### Example
```kotlin
animation.direction = Direction.BACKWARDS
```
```
--------------------------------
### createDefaultBindableArtboard
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/file.md
Creates a BindableArtboard from the file's default artboard, optimized for data binding. Ensure to release the returned BindableArtboard after use.
```APIDOC
## createDefaultBindableArtboard
### Description
Creates a `BindableArtboard` instance using the file's default artboard. This method is designed for scenarios where data binding is required and a default artboard is available. The returned `BindableArtboard` must be released to prevent memory leaks.
### Method
`fun createDefaultBindableArtboard(
viewModelInstance: ViewModelInstance? = null
): BindableArtboard
`
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
None
### Parameters
- **viewModelInstance** (`ViewModelInstance?`) - Optional - Defaults to `null`. An optional `ViewModelInstance` to bind to the artboard.
### Returns
- `BindableArtboard` — The default bindable artboard instance.
### Throws
- `ArtboardException` — if no default artboard exists in the file.
### Example
```kotlin
val artboard = file.createDefaultBindableArtboard()
```
```
--------------------------------
### Create ViewModel Instance by Index
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/viewmodel.md
Creates a ViewModel instance using the definition at a specific zero-based index within the Rive file. Useful for accessing instances by their order.
```kotlin
val instance = viewModel.createInstanceFromIndex(0)
```
--------------------------------
### Get Animation Names
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/artboard.md
Retrieves a list containing the names of all animations within the artboard.
```kotlin
val animationNames: List
```
--------------------------------
### Custom FileAssetLoader Interface
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/configuration.md
Implement this interface to create custom logic for loading Rive file assets.
```kotlin
interface FileAssetLoader {
fun loadContents(asset: FileAsset): Boolean
fun setRendererType(rendererType: RendererType)
}
```
--------------------------------
### Handle State Machine Events
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/statemachineinstance.md
Sets up a listener to receive and handle events fired by the state machine during transitions, such as URL navigation or general events.
```kotlin
val listener = object : RiveFileController.Listener {
override fun onRiveEventReceived(event: RiveEvent) {
when (event) {
is RiveOpenURLEvent -> {
val url = event.url
// Handle URL navigation
}
is RiveGeneralEvent -> {
val name = event.name
// Handle general event
}
}
}
}
```
--------------------------------
### Create ViewModel Instance by Name
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/viewmodel.md
Creates a ViewModel instance by matching the provided name to a named instance definition in the Rive file. Ideal for accessing specific, named states.
```kotlin
val instance = viewModel.createInstanceFromName("DefaultSettings")
```
--------------------------------
### Get State Machine Count
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/artboard.md
Returns the total number of state machines present in the artboard.
```kotlin
val stateMachineCount: Int
```
--------------------------------
### Push Perfetto Config to Device
Source: https://github.com/rive-app/rive-android/blob/master/tools/perfetto/README.md
Use this command to push the Perfetto configuration file to the Android device's temporary storage.
```bash
adb push tools/perfetto/rive-trace.textproto /data/local/tmp/rive-trace.textproto
```
--------------------------------
### workEnd
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/linearanimationinstance.md
Gets the end frame of the animation's work area. Only meaningful if workStart is not -1.
```APIDOC
## workEnd
### Description
End frame of the animation's work area.
### Type
`Int` (read-only)
### Notes
Only meaningful if `workStart != -1`
```
--------------------------------
### Handling RiveEvent Types
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/riveevent.md
Demonstrates how to handle different types of Rive events, such as URL opening or general events.
```kotlin
when (event.type) {
EventType.OpenURLEvent -> // Handle URL
EventType.GeneralEvent -> // Handle general event
}
```
--------------------------------
### duration
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/linearanimationinstance.md
Gets the total duration of the animation in frames. This value does not account for work start/end markers.
```APIDOC
## duration
### Description
Gets the total duration of the animation in frames. This value does not account for work start/end markers.
### Property
`val duration: Int`
### Type
`Int` (read-only)
### Notes
This does not account for work start/end markers
### Example
```kotlin
val totalFrames = animation.duration
```
```
--------------------------------
### Playing Multiple Animations
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/README.md
Shows how to play and blend multiple animations simultaneously on an artboard. Configure the mix (blend strength) for each animation to control their intensity.
```kotlin
val anim1 = artboard.animation("Walk")
val anim2 = artboard.animation("Wave")
// Configure mix (blend strength)
anim1.mix = 0.8f // 80% intensity
anim2.mix = 0.2f // 20% intensity
// Advance both
anim1.advanceAndGetResult(deltaTime)
anim2.advanceAndGetResult(deltaTime)
// Apply both
anim1.apply()
anim2.apply()
```
--------------------------------
### Get Animation by Index
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/artboard.md
Retrieves a LinearAnimationInstance by its zero-based index. Use this to control animation playback.
```kotlin
val animation = artboard.animation(0)
animation.play()
```
--------------------------------
### firstStateMachine
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/artboard.md
Retrieves the first state machine instance associated with this artboard.
```APIDOC
## firstStateMachine
### Description
The first state machine in the artboard.
### Property Signature
```kotlin
val firstStateMachine: StateMachineInstance
```
### Type
`StateMachineInstance` (read-only)
### Throws
- **StateMachineException** — if no state machines exist
```
--------------------------------
### Create Bindable Artboard by Name
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/file.md
Create a BindableArtboard for data binding using an artboard's name. The returned BindableArtboard must also be released.
```kotlin
val bindableArtboard = file.createBindableArtboardByName("DataDisplay")
bindableArtboard.release()
```
--------------------------------
### Initialize Rive and Use RiveAnimationView
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/README.md
Initialize the Rive runtime in your Application class and use RiveAnimationView in your layout to display and control animations.
```kotlin
import android.app.Application
import app.rive.runtime.kotlin.core.Rive
import app.rive.runtime.kotlin.RiveAnimationView
// 1. Initialize Rive (in Application.onCreate)
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
Rive.init(this)
}
}
// 2. Use RiveAnimationView in XML or code
// XML:
// 3. Control animations in Activity
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val riveView = findViewById(R.id.rive_view)
// Play specific animation
riveView.play("Idle")
// Pause/stop
riveView.pause()
riveView.stop()
}
}
```
--------------------------------
### volume
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/artboard.md
Gets or sets the audio volume for this artboard, ranging from 0.0 (silent) to 1.0 (full volume).
```APIDOC
## volume
### Description
Audio volume for this artboard (0.0 to 1.0).
### Property Signature
```kotlin
var volume: Float
```
### Type
`Float` (read-write, internal)
```
--------------------------------
### height
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/artboard.md
Gets or sets the height of the artboard. This allows dynamic resizing of the artboard's display area.
```APIDOC
## height
### Description
The height of the artboard.
### Property Signature
```kotlin
var height: Float
```
### Type
`Float` (read-write)
### Example
```kotlin
artboard.height = 600f
```
```
--------------------------------
### Build Rive Android with Specific ABIs
Source: https://github.com/rive-app/rive-android/blob/master/README.md
Build the Rive Android library including only specified application binary interfaces (ABIs).
```bash
./gradlew :kotlin:assembleRelease -PabiFilters=arm64-v8a
```
```bash
./gradlew :kotlin:assembleRelease -PabiFilters="arm64-v8a,armeabi-v7a"
```
--------------------------------
### Chaining Multiple State Machine Inputs
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/smiinputs.md
Demonstrates setting one input's value based on the current value of another input, allowing for complex conditional logic.
```kotlin
val walkSpeed = stateMachine.input("walkSpeed") as SMINumber
val isRunning = stateMachine.input("isRunning") as SMIBoolean
walkSpeed.value = if (isRunning.value) 200f else 50f
```
--------------------------------
### Get Animation Count
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/artboard.md
Returns the total number of animations present in the artboard. Useful for iterating through all animations.
```kotlin
val animationCount: Int
```
```kotlin
for (i in 0 until artboard.animationCount) {
val anim = artboard.animation(i)
}
```
--------------------------------
### loop
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/linearanimationinstance.md
Gets or sets the looping behavior of the animation. Supports one-shot, continuous loop, ping-pong, or automatic.
```APIDOC
## loop
### Description
Gets or sets the looping behavior of the animation. Supports one-shot, continuous loop, ping-pong, or automatic.
### Property
`var loop: Loop`
### Type
`Loop` (read-write)
### Values
- `Loop.ONESHOT` — Play once
- `Loop.LOOP` — Repeat continuously
- `Loop.PINGPONG` — Play forward and backward
- `Loop.AUTO` — Use configured loop mode
### Example
```kotlin
animation.loop = Loop.LOOP
```
```
--------------------------------
### Manually Initialize C++ Environment
Source: https://github.com/rive-app/rive-android/blob/master/_autodocs/api-reference/rive.md
Manually initializes JNI bindings after loading native libraries independently. Use this if you load libraries with System.loadLibrary() before Rive initialization, often in split APK scenarios.
```kotlin
System.loadLibrary("c++_shared")
System.loadLibrary("rive-android")
Rive.initializeCppEnvironment()
```