Choicely RN — Android Integration Guide
Integrate the Choicely React Native SDK into your native Android project.Versions
| Artifact | Version |
|---|---|
com.choicely.sdk:android-core | 1.1.2 |
com.choicely.sdk:android-rn | 0.0.2 |
com.choicely.sdk:choicely-rn-gradle | 0.0.4 |
Prerequisites
- Node.js >= 20
- Android SDK with CMake
- Git
- Java 17
Project Structure (after setup)
Setup
Step 1 — Clone the Choicely RN repo
The folder must be namedapp-react-nativeby default. To use a different name, setchoicelyRnDiringradle.properties(see Step 2).
Step 2 — gradle.properties
Step 3 — settings.gradle
WhyincludeBuildandreactSettingscan’t be automated by a plugin: They run in Gradle’s settings phase — before any plugin from Maven Central can load. These will always need to be in yoursettings.gradle.
Step 4 — Root build.gradle
Step 5 — App build.gradle
Also needed — react-native.config.js
File: app-react-native/react-native.config.js
Must use dots in the filename — NOT react-native-config.js.
Step 6 — MyApplication.java
Extend ChoicelyRNApplication instead of Application and initialise both the RN engine and the Choicely SDK.
Bundle loading explained
serLoadRemoteBundle second arg | Behaviour |
|---|---|
false | Loads the local JS bundle packaged in your APK. Run npm run bundle inside app-react-native/ to rebuild it after JS changes. |
true | Loads the remote bundle from the Choicely server at runtime. Use this in production. |
Artifacts Overview
Gradle Plugin: com.choicely.sdk:choicely-rn-gradle
Distributed via Maven Central Snapshots. Provides two plugin IDs:
| Plugin ID | Applied in | Purpose |
|---|---|---|
com.choicely.rn.setup | Root build.gradle | Node binary detection, lib patching, CMake fix, PATH injection |
com.choicely.react | App build.gradle | Configures react{} paths, ext vars, autolinkLibrariesWithApp() |
Runtime Library: com.choicely.sdk:android-rn
AAR library containing:
| Component | Description |
|---|---|
ChoicelyRNApplication | Abstract Application implementing ReactApplication, manages multiple ReactHost instances |
ChoicelyRNHost | Extends DefaultReactNativeHost, handles JS bundle loading (asset or remote) |
ChoicelyDefaultReactHost | Factory for creating ReactHost instances |
ChoicelyReactNativeFragment | Fragment for embedding RN views in native screens |
RNFragmentWrapper | Wrapper around the RN fragment |
ChoicelyDeepLinkScreenActivity | Activity for deep link handling |
ChoicelyBridgePackage / ChoicelyRNBridge | Native-to-RN bridge module |
ChoicelyRNConfig | Config for current version/app key for remote bundles |
ChoicelyRemoteBundle | Handles remote JS bundle downloading |
com.choicely.sdk:android-corecom.facebook.react:react-android:0.82.0com.facebook.react:hermes-android:0.82.0androidx.databinding:*:8.13.0org.jetbrains.kotlin:kotlin-stdlib:2.1.21
Build Commands
Renaming the RN folder
Change one line ingradle.properties:
What the Gradle plugin handles automatically
| What | Plugin ID |
|---|---|
Node binary detection (macOS Homebrew / /usr/local) | com.choicely.rn.setup |
Patching third-party libs that hardcode "node" | com.choicely.rn.setup |
| Injecting Node into PATH for all Exec tasks | com.choicely.rn.setup |
| CMake cache clean fix | com.choicely.rn.setup |
react{} block (node, cliFile, reactNativeDir, codegenDir) | com.choicely.react |
autolinkLibrariesWithApp() | com.choicely.react |
What still requires manual setup (Gradle hard limits)
| What | Why |
|---|---|
includeBuild(".../gradle-plugin") in settings.gradle | Settings phase — no plugin can run before this |
reactSettings { autolinkLibrariesFromCommand(...) } | Settings phase — same reason |
apply plugin: 'com.facebook.react' in app/build.gradle | ClassLoaderScope — can’t be applied from another plugin |
Troubleshooting
| Error | Fix |
|---|---|
Could not find project.android.packageName | Rename to react-native.config.js (dots, not dashes) |
includeBuild path not found | Run npm install in app-react-native/ first |
pluginManagement must appear first | No code before pluginManagement {} in settings.gradle |
Node binary not found | Plugin finds Node automatically; ensure Homebrew or nvm is installed |
Cannot find module '@react-native/codegen' | choicelyRnDir may point to wrong folder — check gradle.properties |
Failed to apply plugin 'com.choicely.react' | Add apply plugin: 'com.choicely.rn.setup' in root build.gradle |
2 files found with path 'lib/arm64-v8a/libworklets.so' | Add packagingOptions { pickFirst 'lib/*/libworklets.so' } in app build.gradle |
Included build 'choicely-rn-android/rn-gradle-plugin' does not exist | Remove the includeBuild("choicely-rn-android/rn-gradle-plugin") line — the plugin is now distributed via Maven |
