Skip to content

Commit

Permalink
PLS Android Integration
Browse files Browse the repository at this point in the history
- Supports PLS & Skia renderer via a Kotlin flag!
- Adds PLS in the build flow
  - Fix `premake` for Android adding in the architecture parameter to output the correct version
  - In `rive-android` the PLS repo name is stored in a secret variable but is effectively pointing to https://github.com/rive-app/rive-pls
- Fixes a missing flag for logging in debug builds
- Adds a new workflow for `rive-android` to build the AAR on push so we can easily test whether the build succeeds or fails before releasing
- Some refactoring to rename some classes, methods, et al.
- Some tests (definitely not enough of 'em here!) in Kotlin
  - Adds a custom runner to make sure we're running on a devices as PLS does not support emulators. Unfortunately, this means we can't run PLS View tests on the Emulator, which is a bit disappointing, but maybe we can figure that out at some point? Or stub it out if/when we *really* need it.
- Other miscellaneous fixes

Diffs=
9b75cdb96 Rive Renderer Android Integration (#5539)

Co-authored-by: Umberto Sonnino <[email protected]>
  • Loading branch information
umberto-sonnino and umberto-sonnino committed Jul 21, 2023
1 parent 280bdc7 commit ab45d45
Show file tree
Hide file tree
Showing 60 changed files with 2,028 additions and 1,199 deletions.
69 changes: 69 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Build

on:
push:
branches: [master]

jobs:
publish:
name: Build the artifacts
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- name: Check out code
uses: actions/checkout@v3
with:
submodules: true
token: ${{ secrets.PAT_GITHUB }}

- name: Rive Renderer Repo
uses: actions/checkout@v3
with:
submodules: true
repository: ${{ secrets.RIVE_RENDERER_REPO }}
token: ${{ secrets.PAT_GITHUB }}
path: ./submodules/pls

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-region: us-west-2
role-to-assume: ${{ secrets.ACTIONS_ROLE }}

- name: Update Java
uses: actions/setup-java@v3
with:
distribution: "zulu"
java-version: "17"

- name: Setup Android SDK
uses: android-actions/setup-android@v2

- name: Install NDK & tools
# Starts from: pwd => /home/runner/work/rive/rive
# ANDROID_HOME => /usr/local/lib/android/sdk
run: |
set -x
echo "y" | sudo ${ANDROID_HOME}/tools/bin/sdkmanager --install 'build-tools;30.0.3' platform-tools --sdk_root=${ANDROID_SDK_ROOT}
cd ${ANDROID_HOME}
wget -q https://dl.google.com/android/repository/android-ndk-r25b-linux.zip
unzip -q android-ndk-r25b-linux.zip
echo "y" | sudo ${ANDROID_HOME}/tools/bin/sdkmanager --install 'cmake;3.22.1' --channel=0 --sdk_root=${ANDROID_SDK_ROOT}
- name: Installing pre-requisites
run: |
set -x
# Install some dependencies & premake5
sudo apt update && sudo apt-get -y install build-essential cmake clang g++ libgl1-mesa-dev libvorbis-dev libvpx-dev ninja-build
wget -q https://github.com/premake/premake-core/releases/download/v5.0.0-alpha15/premake-5.0.0-alpha15-linux.tar.gz
tar -xf premake-5.0.0-alpha15-linux.tar.gz
sudo mv premake5 /usr/local/bin
- name: Build Android
env:
# ANDROID_SDK_ROOT has been in the env by 'setup-android' above
# and is => /usr/local/lib/android/sdk
NDK_PATH: ${{ env.ANDROID_SDK_ROOT }}/android-ndk-r25b
run: ./gradlew kotlin:assembleRelease
8 changes: 8 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ jobs:
with:
submodules: true
token: ${{ secrets.PAT_GITHUB }}

- name: Rive Renderer Repo
uses: actions/checkout@v3
with:
submodules: true
repository: ${{ secrets.RIVE_RENDERER_REPO }}
token: ${{ secrets.PAT_GITHUB }}
path: ./submodules/pls

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v2
Expand Down
19 changes: 14 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,25 @@ jobs:
id-token: write
contents: read
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: us-west-2
role-to-assume: ${{ secrets.ACTIONS_ROLE }}
- name: Checkout Code
uses: actions/checkout@v3
with:
submodules: true
token: ${{ secrets.PAT_GITHUB }}
- name: Rive Renderer Repo
uses: actions/checkout@v3
with:
submodules: true
repository: ${{ secrets.RIVE_RENDERER_REPO }}
token: ${{ secrets.PAT_GITHUB }}
path: ./submodules/pls

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: us-west-2
role-to-assume: ${{ secrets.ACTIONS_ROLE }}


- name: Update Java
uses: actions/setup-java@v2
Expand Down
2 changes: 1 addition & 1 deletion .rive_head
Original file line number Diff line number Diff line change
@@ -1 +1 @@
420d27a5bc052e39f9592f1561070ad509589ed1
9b75cdb96c2e7dc1f15551cbbf3e0f320759c078
13 changes: 6 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,16 @@ The underlying [C++ runtime](https://github.com/rive-app/rive-cpp) is mapped to
the `app.rive.runtime.kotlin.core` namespace. These allow more fine grained control for more complex
animation loops. Our high level views are simply built on top of this.

#### `/cpp` && `/submodules`

This runtime is built on top of our [C++ runtime](https://github.com/rive-app/rive-cpp). This is
included as a submodule in `/submodules`. The `/cpp` folder contains the C++ side of our Android bindings and is located at `/kotlin/src/main/cpp`

### `/app`

Multiple sample activities can be found here, this can be a useful reference for getting started
with using the runtimes.

### `/cpp` && `/submodules`

This runtime is built on top of our [C++ runtime](https://github.com/rive-app/rive-cpp). This is
included as a submodule in `/submodules`. The `/cpp` folder contains the C++ side of our bindings
into android.

## Development workflow

### Running Locally
Expand All @@ -39,7 +38,7 @@ run the test suite:

- Open the project in Android Studio
- Select the "Project" view (upper-right corner)
- Right-click on kotlin/src/androidTest and select "Run All Tests"
- Right-click on `kotlin/src/androidTest` and select "Run All Tests"

### Building `.so` files

Expand Down
4 changes: 2 additions & 2 deletions MEMORY_MANAGEMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ The diagram below illustrates the class hierarchy for `RiveAnimationView` highli
|RiveTextureView |
+----------------------+
|abstract |
|renderer: RendererSkia|
|renderer: Renderer |
+----------+-----------+
|
|
Expand Down Expand Up @@ -85,7 +85,7 @@ which in turn will cascade the `release()` call on its own dependents.
has
|
+--------------------+ +------------+ +------+-----+
|RiveArtboardRenderer+-is-a->|RendererSkia+-is-a->|NativeObject|
|RiveArtboardRenderer+-is-a->| Renderer +-is-a->|NativeObject|
+---------+----------+ +------------+ +------^-----+
| |
has |
Expand Down
74 changes: 67 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

# Rive Android

![Rive hero image](https://rive-app.notion.site/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2Fff44ed5f-1eea-4154-81ef-84547e61c3fd%2Frive_notion.png?table=block&id=f198cab2-c0bc-4ce8-970c-42220379bcf3&spaceId=9c949665-9ad9-445f-b9c4-5ee204f8b60c&width=2000&userId=&cache=v2)
![Rive hero image](https://cdn.rive.app/rive_logo_dark_bg.png)

An Android runtime library for [Rive](https://rive.app).

Expand All @@ -14,12 +14,13 @@ the [Maven](https://search.maven.org/artifact/app.rive/rive-android) repository.

## Table of contents

- :star: [Rive Overview](#rive-overview)
- ⭐️ [Rive Overview](#rive-overview)
- 🚀 [Getting Started & API docs](#getting-started)
- :mag: [Supported Versions](#supported-versions)
- :books: [Examples](#examples)
- 🔍 [Supported Versions](#supported-versions)
- 🧪 [Experimental Features](#experimental-features)
- 📚 [Examples](#examples)
- 👨‍💻 [Contributing](#contributing)
- :question: [Issues](#issues)
- [Issues](#issues)

## Rive Overview

Expand All @@ -28,9 +29,9 @@ create and run interactive animations anywhere. Designers and developers use our
editor to create motion graphics that respond to different states and user inputs. Our lightweight
open-source runtime libraries allow them to load their animations into apps, games, and websites.

:house_with_garden: [Homepage](https://rive.app/)
🏡 [Homepage](https://rive.app/)

:blue_book: [General help docs](https://help.rive.app/)
📘 [General help docs](https://help.rive.app/)

🛠 [Learning Rive](https://rive.app/learn-rive/)

Expand Down Expand Up @@ -58,6 +59,32 @@ showcases a number of ways to manipulate Rives, including:
- Utilizing a low-level API to build a render loop for more control over scenes
- ...and more!

## Experimental Features

The Rive renderer is available _experimentally_ in `7.0.0`.

Read more about the Rive Renderer [here](https://rive.app/renderer).

Please note that we don't recommend it for production builds yet as it's not fully compatible with the current Rive feature set (i.e., rendering images isn't supported yet). You might also encounter incompatibilities with specific devices - for example, the new renderer won't work on emulators just yet but only on physical devices.

Your feedback is greatly appreciated during this stage and we'd love to hear from you!

To use the new Rive renderer you can specify the parameter in XML:

```xml
<app.rive.runtime.kotlin.RiveAnimationView
app:riveRenderer="Rive"
… />
```

Alternatively, specify the renderer when initializing Rive:

```kotlin
Rive.init(applicationContext, defaultRenderer = RendererType.Rive)
```

This default value can still be overriden via XML.

## Contributing

We love contributions! Check out our [contributing docs](./CONTRIBUTING.md) to get more details into
Expand All @@ -69,3 +96,36 @@ Have an issue with using the runtime, or want to suggest a feature/API to help m
life better? Log an issue in our [issues](https://github.com/rive-app/rive-android/issues) tab! You
can also browse older issues and discussion threads there to see solutions that may have worked for
common problems.

### Known Issues

After `rive-android:6.0.0`, CMake is building the library, and you might run into the following error when `rive-android` is used alongside other native libraries:

```shell
Execution failed for task ':app:mergeDebugNativeLibs'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.MergeNativeLibsTask$MergeNativeLibsTaskWorkAction
> 2 files found with path 'lib/arm64-v8a/libc++_shared.so' from inputs:
```
You can fix this by adding this in your `build.gradle`:
```gradle
android {
packagingOptions {
pickFirst "lib/x86/libc++_shared.so"
pickFirst "lib/x86_64/libc++_shared.so"
pickFirst "lib/armeabi-v7a/libc++_shared.so"
pickFirst "lib/arm64-v8a/libc++_shared.so"
}
}
```
### Breaking Changes
#### **7.0.0**
- `RendererSkia` is now called to `Renderer`
25 changes: 25 additions & 0 deletions app/src/androidTest/java/app/rive/runtime/example/DeviceRunner.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import org.junit.Assume.assumeFalse
import org.junit.runner.notification.RunNotifier
import org.junit.runners.BlockJUnit4ClassRunner
import org.junit.runners.model.FrameworkMethod
import org.junit.runners.model.InitializationError
import org.junit.runners.model.Statement

annotation class OnDevice

class RunOnDevice(testClass: Class<*>) : BlockJUnit4ClassRunner(testClass) {
@Throws(InitializationError::class)
constructor(testClass: Class<*>, notifier: RunNotifier) : this(testClass)

override fun methodBlock(method: FrameworkMethod): Statement {
return object : Statement() {
@Throws(Throwable::class)
override fun evaluate() {
// Check whether this is an emulator. If it is skip the test.
assumeFalse(TestUtils.isProbablyRunningOnEmulator)
// Continue with the usual test
method.invokeExplosively(testClass.javaClass.newInstance())
}
}
}
}
Loading

0 comments on commit ab45d45

Please sign in to comment.