This example demonstrates the evaluation of a Split feature flag using Android Suite.
The project uses Baseline Profiles to improve app performance and Jetpack Macrobenchmark to automate testing.
To run the code you'll need
- A Split.io account with the Measurement and Learning add-on, or a free trial Split account.
- Android Studio Hedgehog (2023.1.1) or newer
- Android Gradle Plugin 8.0 or higher
- A physical Android device (or virtual device on the emulator) with Android 9 (API level 28) or higher
To get started, follow these steps
-
Clone this repo from Android Studio.
-
Add the following line to your local.properties file
SPLIT_CLIENTSIDE_API_KEY="<your_split_sdk_client-side_api_key>"
You can get your client-side SDK API key from your Admin settings in app.split.io. (After you log in, click the top button on the left-hand navigation bar, then click Admin settings | API keys.)
-
Sync project with gradle files.
-
Choose one of the
:app
build variants. The:baselineprofile
benchmarkRelease (default)
variant should be selected by default. -
In Android Studio's Device Manager, add a virtual device (API level 28 or higher), or select it if it is already added.
-
Run 'app' or run the
scrollCompilationBaselineProfiles()
test.
If you'd like to see how to set up the feature flags in Split UI and enjoy IFID superpowers, see the blog: 5 Steps to Instant Feature Impact Detection. Since you are already looking into the code, check it out and see Split's powerful IFID capabilities in action!
This code is based on the Android Codelab example code found at https://github.com/android/codelab-android-performance.
Note that the original codelab-android-performance
repository contains two projects (examples) in two subfolders (benchmarking
and baseline-profiles
). We have removed the benchmarking
project, and restructured the baseline-profiles
project to allow this repo to be cloned and opened directly in Android Studio.
To create this Split Android Suite example from the baseline-profiles
Codelab example, the following additional changes were made
- the
main
branch of the Codelab repo is not copied into this repository - the
end
branch of the Codelab repo is renamedmain
- Split Android Suite code is added to evaluate a feature flag