Jetpack Compose version of the API demo. Mirrors cases from APIExample/ but uses
@Composable functions instead of Fragments + XML layouts. Kotlin only.
./gradlew assembleDebug # build debug APK
./gradlew installDebug # build + install to connected device
./gradlew test # unit tests
./gradlew connectedAndroidTest # instrumented tests (device required)Edit local.properties in the project root (not in app/):
AGORA_APP_ID=YOUR_APP_ID
AGORA_APP_CERT=YOUR_CERT
The build will throw a GradleException if AGORA_APP_ID is missing or empty.
Values are injected as BuildConfig.AGORA_APP_ID / BuildConfig.AGORA_APP_CERT at compile time.
Registration is manual — there is no reflection in this project.
-
Create
app/src/main/java/io/agora/api/example/compose/samples/MyNewCase.kt:@Composable fun MyNewCase() { // RtcEngine + state here }
Follow the two-function pattern: a public stateful entry + a private stateless
*Viewfunction. SeeJoinChannelVideo.ktas the canonical reference. -
Register in
model/Examples.kt— add toBasicExampleListorAdvanceExampleList:Example(R.string.example_my_new_case) { MyNewCase() }
-
Add the display string to
app/src/main/res/values/strings.xml:<string name="example_my_new_case">My New Case</string>
No nav_graph.xml changes needed. Navigation routes by list index automatically.
- Do NOT use XML layouts,
Fragment, orViewBinding— Compose only. - Do NOT use
View-based widgets directly in Compose UI — wrap withAndroidViewif unavoidable. RtcEnginemust be created insideremember { }and destroyed insideDisposableEffect(lifecycleOwner) { onDispose { } }— key must belifecycleOwner, notUnit; wrong key means cleanup never fires on back navigation.- Always call
rtcEngine.leaveChannel()beforeRtcEngine.destroy()inonDispose. - Permissions use
rememberLauncherForActivityResult(ActivityResultContracts.RequestMultiplePermissions()). IRtcEngineEventHandlercallbacks are safe to mutate Compose state directly (snapshot system is thread-safe).
.kiro/skills/add-new-case/— step-by-step guide for adding a new Compose case (template,rememberSaveablerules, verify checklist). ReadSKILL.mdinside before writing any code..kiro/skills/query-cases/— query existing cases by API, group, or list position; usesARCHITECTURE.mdas fast index.
.kiro/hooks/build-on-task-complete.json— runsassembleDebugautomatically after each spec task completes
| File | Inclusion | Purpose |
|---|---|---|
.kiro/steering/project-routing.md |
Always | which sub-project to use for a given scenario; hard constraints on file sharing |
.kiro/steering/coding-standards.md |
Always | RtcEngine lifecycle rules, Kotlin/Compose standards, naming conventions |
.kiro/steering/complex-case-spec.md |
Manual | when and how to use the Spec workflow for complex cases |
ARCHITECTURE.md— full directory layout, Composable case pattern, registration details