Skip to content

Commit

Permalink
feat: add preview build variant to android example
Browse files Browse the repository at this point in the history
This adds an additional build variant to the Android example app, called `preview`:
- set to be the default (which needs to be tested, I believe this is only for the first time you open the project locally)
- this variant will use the latest hosted version of Rive Android
- additional README information to configure build variants

With this, it should be much easier for people to evaluate the example, without needing to do any additional config locally.

What this means for us is that when developing locally, ensure you have the correct build variant set: `debug`.

This PR also replaces the network image that is loaded in the first example page, that has been causing issues. Requires further investigation but keeping it in is a bad experience for anyone running the app themselves.

Diffs=
0c4483cd0 feat: add preview build variant to android example (#6088)

Co-authored-by: Gordon <[email protected]>
  • Loading branch information
HayesGordon and HayesGordon committed Oct 13, 2023
1 parent fffe60f commit 4e78ad1
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .rive_head
Original file line number Diff line number Diff line change
@@ -1 +1 @@
b4ef09a6d619423eb7a4b96d34d4acfd62dbc527
0c4483cd00907f507eff8b13b5b76276db32c773
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ with using the runtimes.

### Running Locally

Open the project in Android Studio and ensure you can run "Make Project" to run the Gradle build.
Run the `app/` example app that runs the local Android runtime code to test out changes on a device
or emulator.
Open the project in Android Studio and ensure the `app` build variant is set to `debug` (or manually update the dependencies to use the local Rive runtime as a resource) and that you can run "Make Project" to run the Gradle build.

In Android Studio, to select which build variant to build and run, go to **Build > Select Build Variant** and select a build variant from the menu.

### Testing

Expand Down
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,19 @@ is **33**.

## Examples

Check out the `app/` folder to see an example application using the Rive Android runtime. It
showcases a number of ways to manipulate Rives, including:
Check out the `app/` folder to see an example application using the Rive Android runtime.

To run the example app set the `app` build variant to `preview`. In Android Studio, to select which build variant to build and run, go to **Build > Select Build Variant** and select a build variant from the menu.

The `preview` build variant makes use of the hosted Rive dependency. If you're looking to contribute, set the build variant to `debug` and see `CONTRIBUTING.md` for more information. Building this variant will require additional configuration and setup.

The example showcases a number of ways to manipulate Rives, including:

- How to include Rive files into the project and reference them
- Setting layout and loop mode options
- Displaying single or multiple animations / artboards on one component
- Setting up and manipulating a state machine via inputs
- Handling events
- Utilizing a low-level API to build a render loop for more control over scenes
- ...and more!

Expand Down
12 changes: 11 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ android {
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
preview {
debuggable true
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
getIsDefault().set(true)
signingConfig signingConfigs.debug
}
}

compileOptions {
Expand Down Expand Up @@ -63,7 +71,9 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.fragment:fragment-ktx:1.6.1'
implementation project(path: ':kotlin')
debugImplementation project(path: ':kotlin')
releaseImplementation project(path: ':kotlin')
previewImplementation 'app.rive:rive-android:+'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.1'
implementation 'com.google.android.material:material:1.9.0'
implementation 'androidx.activity:activity-compose:1.7.2'
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/simple.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/simple_view_asset"
app:riveFit="COVER"
app:riveUrl="https://cdn.rive.app/animations/truck.riv" />
app:riveUrl="https://cdn.rive.app/animations/vehicles.riv" />

</androidx.constraintlayout.widget.ConstraintLayout>

0 comments on commit 4e78ad1

Please sign in to comment.