Is there anything specific config that I need to u...
# ask-ai
p
Is there anything specific config that I need to use when building and testing react native android app on an android emulator ? Looks like my webrtc connection on emulator is failing with
could not establish pc connection
but same endpoint connection from normal browser on the same latptop is working fine
t
Thanks for reaching out, mithun. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hi there! To help you smoothly resolve the WebRTC connection issues while testing your React Native Android app on an emulator, let's walk through some important configurations together: • Enable Java 8 Support: Please add the following to your
android/app/build.gradle
file:
Copy code
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}
• Fix WebRTC Runtime Issue: Kindly include this line in your
android/gradle.properties
file:
Copy code
android.enableDexingArtifactTransform.desugaring=false
• Android 9 Crash Fix: For this, update your
android/app/build.gradle
like so:
Copy code
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_11
}
• Update Gradle Version: Make sure your
android/build.gradle
is using Gradle plugin version
7.3.1
and the Gradle wrapper version is
7.4+
. • Permissions: Also, double-check that your
AndroidManifest.xml
has the necessary permissions for camera, microphone, and internet access. Following these steps usually does the trick to fix the WebRTC connection problems on the emulator. If you run into any hiccups or have more questions, feel free to reach out—I’m here to help! Sources: android/src/main/java/com/oney/WebRTCModule/WebRTCModule.java
p
undamental Issue Confirmed: Android Emulator + Private VPN Network Based on the extensive analysis of server logs and debugging: The Core Problem 1. Android Emulator NAT Network: Uses 10.x.x.xxx which is isolated from the host 2. VPN Private Network: LiveKit server is on 10.xxx.x.x private VPC 3. Double NAT Issue: Emulator → Host → VPN → Private Server 4. TURN Configuration Ignored: React Native LiveKit not properly using TURN relay Why Browser Works vs Android Emulator Fails - Browser: Runs on host machine with direct VPN access - Android Emulator: Isolated NAT network that can't receive incoming connections from private VPC
t
Let's work together to resolve the WebRTC connection issue you're experiencing with the Android Emulator's NAT network and private VPN setup. Here are some steps that can help: • Enable TURN Relays: Please make sure TURN is properly configured and accessible. You'll want to allow outbound traffic to
*.turn.livekit.cloud
on TCP port 443. • Force TURN Usage: To help with connectivity, set the ICE transport policy to relay-only in your client configuration like this:
Copy code
connectOpts.rtcConfig = { iceTransportPolicy: 'relay' }
• Whitelist Required Domains and Ports: It’s important that the emulator’s host network allows access to the following: •
*.livekit.cloud
– TCP 443 (signaling) •
*.turn.livekit.cloud
– TCP 443 (TURN/TLS) •
*.host.livekit.cloud
– UDP 3478 (TURN/UDP) • UDP 50000–60000 (optional, for direct media) • Test Connectivity: You can use LiveKit's connection test utility to check WebSocket, WebRTC, and TURN access to make sure everything is working smoothly. • VPN-Specific Adjustments: If your VPN happens to block UDP traffic, try configuring TURN over TCP/TLS as the default transport, or temporarily disable the VPN to see if that improves connectivity. Following these steps should help clear up the double NAT issue and get your WebRTC connection working properly. If you run into any trouble or have questions, please don’t hesitate to reach out—I’m here to help! Sources: Documentation/ImprovingCallReliability.md | Firewall Tips | Diagnosing Connection Errors with Connection Test Utility | Configuring firewalls | LiveKit Docs