android(call): fix LiveKit audio API import + audioswitch duplicate-class

JitPack fix worked; two new failures surfaced, both fixed here:

1) checkDebugDuplicateClasses: LiveKit 2.29.2 already BUNDLES a fork
   (com.github.davidliu:audioswitch) carrying the same com.twilio.audioswitch
   classes at runtime, so our explicit `implementation com.twilio:audioswitch`
   put both on the runtime classpath. Switch it to `compileOnly` — we get the
   AudioDevice types at compile time, runtime uses only LiveKit's bundled fork.
   (Also clears the "namespace used in multiple modules" merge warning.)

2) CallMedia.kt: `Unresolved reference: AudioOptions`. In 2.29.2 AudioOptions
   is declared in package io.livekit.android (inside LiveKitOverrides.kt), not
   io.livekit.android.audio. Corrected the import. Verified AudioSwitchHandler's
   API (registerAudioDeviceChangeListener / availableAudioDevices /
   selectedAudioDevice / selectDevice) against the v2.29.2 source.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
SravanandClaude Opus 4.8 committed 2026-10-30 20:42:00 +05:30
1 parent 7cd3c3afff
commit ea4d65274e
2 files changed
+7 -3

No files matched your search

@@ -88,6 +88,10 @@ dependencies {
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutinesVersion"
// Native call media (background audio) + audio-device routing (speaker/bluetooth/earpiece).
implementation "io.livekit:livekit-android:$livekitVersion"
// AudioDevice types used by LiveKit's AudioSwitchHandler; declared so they're on our compile classpath.
implementation "com.twilio:audioswitch:$audioswitchVersion"
// AudioDevice types (com.twilio.audioswitch.AudioDevice) used by our CallMedia.kt. LiveKit already BUNDLES a
// fork (com.github.davidliu:audioswitch) that ships these exact classes at RUNTIME — so declaring our own as
// `implementation` put both forks on the runtime classpath and failed checkDebugDuplicateClasses. Use
// `compileOnly`: twilio:audioswitch gives us the types at compile time, while runtime uses only LiveKit's
// bundled fork (binary-identical package/classes) → no duplicate.
compileOnly "com.twilio:audioswitch:$audioswitchVersion"
}