A React Native application demonstrating real-time video calling using Agora SDK with FaceUnity beauty filters and AR effects.
- Real-time Video Calling: Powered by Agora RTC Engine
- Beauty Filters: FaceUnity beauty effects (skin smoothing, whitening, face thinning)
- AR Stickers: Interactive AR stickers and effects
- Cross-platform: Supports both iOS and Android
- Permission Management: Camera and microphone permissions handling
Before running this project, ensure you have:
- Node.js (>= 20.0.0)
- React Native CLI or Expo CLI
- Android Studio (for Android development)
- Xcode (for iOS development, macOS only)
- CocoaPods (for iOS dependencies)
git clone <repository-url>
cd AgoraVideoCall
npm install# Install CocoaPods dependencies
cd ios
pod install
cd ..- Sign up at Agora Console
- Create a new project and get your App ID
- Update
App.tsx:
const appId = 'YOUR_AGORA_APP_ID'; // Replace with your Agora App ID
const channelName = 'your_channel_name'; // Set your channel name
const token = 'YOUR_TOKEN'; // Optional: Add token for productionThe project includes FaceUnity SDK integration:
- iOS: FaceUnity frameworks are located in
ios/FaceUnityFiles/(If you are adding your own FaceUnity resources and frameworks, make sure to add it directly to Xcode > xcworkspace ) - Android: FaceUnity resources are in
android/app/src/main/assets/and the native library AAR inandroid/libs/ - Authentication: Update the
FACEUNITY_AUTHPACKarray inApp.tsxwith your FaceUnity license
CRITICAL: For Android, the FaceUnity extension must be explicitly loaded:
// In App.tsx - Required for Android only
if (Platform.OS === 'android') {
const result = await agoraEngine.loadExtensionProvider('AgoraFaceUnityExtension');
console.log('Android FaceUnity extension load result:', result);
}This step is essential - without loadExtensionProvider(), Android will return error code -3 (extension not found).
⚠️ IMPORTANT:
- FaceUnity licenses are tied to specific package names/bundle IDs. You MUST update your app's package/bundle ID to match your FaceUnity license before the SDK will work.
- Android requires the
android/libs/folder with the FaceUnity AAR file- Android requires explicit
loadExtensionProvider()call before using FaceUnity features
For Android:
- Open
android/app/build.gradle - Update the
applicationIdandnamespace:
android {
namespace "com.yourcompany.yourapp" // Change this
defaultConfig {
applicationId "com.yourcompany.yourapp" // Change this
// ... other configs
}
}For iOS:
- Open
ios/AgoraVideoCall.xcworkspacein Xcode - Select your project target
- Under "Signing & Capabilities", update the Bundle Identifier
- Or update directly in
ios/AgoraVideoCall.xcodeproj/project.pbxproj
For React Native:
- Update
package.jsonname field (optional but recommended) - Update
app.jsonname field if you're using it
Note: You need a valid FaceUnity license to use the beauty and AR features. Contact Agora for licensing information and ensure your license matches your app's package/bundle ID.
├── App.tsx # Main application component
├── utils/ # Utility functions
│ ├── index.ts # Resource path utilities & asset copying for Android
│ ├── log.ts # (not used) Logging utilities
│ └── permissions.ts # (not used)Permission handling
├── ios/
│ └── FaceUnityFiles/ # FaceUnity iOS frameworks and resources (If you are adding your own FaceUnity resources and frameworks, make sure to add it directly to Xcode > xcworkspace)
├── android/
│ ├── libs/ # FaceUnity AAR library (extension_aar-release.aar)
│ └── app/src/main/assets/ # FaceUnity Android resources (bundles, models, etc.)
npm start# Method 1: CLI
npm run ios
# Method 2: Xcode
# Open ios/AgoraVideoCall.xcworkspace in Xcode and build# Method 1: CLI
npm run android
# Method 2: Android Studio
# Open android/ folder in Android Studio and build- Join Channel: Tap "Join" to connect to the video call
- Beauty Effects: Toggle beauty filters on/off
- AR Stickers: Enable/disable AR stickers
- Leave Channel: Tap "Leave" to disconnect
- Video Engine Setup: Initializes Agora RTC engine
- FaceUnity Integration: Loads and manages FaceUnity resources
- Permission Handling: Requests camera/microphone permissions
- UI Controls: Beauty and sticker toggle buttons
- Beauty Effects:
face_beautification.bundle - AR Models: AI face/hand/human processing bundles
- Stickers: Various AR sticker effects
- Makeup: Comprehensive makeup filter system
1. FaceUnity Not Loading (Android)
- Error -3: Extension not found
- Ensure
extension_aar-release.aaris inandroid/libs/folder - Verify
loadExtensionProvider('AgoraFaceUnityExtension')is called before using FaceUnity - Check that your FaceUnity license matches the app's
applicationId
- Ensure
- Error -1: AI model loading failed
- Check that FaceUnity assets are properly copied from APK to device storage
- Verify the
getAbsolutePath()function inutils/index.tsis working correctly
2. FaceUnity Not Loading (General)
- Verify your FaceUnity license is valid and not expired
- Check that all bundle files are properly included in your app bundle
- Ensure package/bundle ID matches your FaceUnity license
- Review console logs for specific error messages
3. Video Not Showing
- Ensure camera permissions are granted
- Check if Agora App ID is correctly configured
- Verify network connectivity
4. iOS Build Errors
- Run
cd ios && pod installto update dependencies - Clean build folder:
cd ios && xcodebuild clean
5. Android Build Errors
- AAR not found: Ensure
android/libs/folder exists with the FaceUnity AAR - Gradle sync issues: Check
android/build.gradlehas correctflatDirrepository configuration - Clean gradle cache:
cd android && ./gradlew clean - Ensure Android SDK tools are up to date
Missing FaceUnity AAR Library:
# Verify the AAR file exists
ls -la android/libs/extension_aar-release.aarGradle Configuration Issues: Check these files have correct configuration:
android/build.gradle- should haveflatDirrepository pointing torootProject.file('libs')android/app/build.gradle- should have the AAR dependency declared
Asset Copying Issues: FaceUnity requires assets to be copied from APK to device storage on Android. Check logs for:
Copying asset: model/ai_face_processor.bundle to /storage/...
Successfully copied: model/ai_face_processor.bundle
Enable debug logs by checking console output. The app uses prefixed logging:
Bacsprefix for general app logs- Look for FaceUnity-specific errors in native logs
- Success logs show:
Bacs FaceUnity Ready!when all components load successfully - Android logs: Use
adb logcat | grep ReactNativeJSto see React Native console logs
react-native-agora: Agora RTC SDKreact-native-safe-area-context: Safe area handlingreact-native-fs: File system accessreact-native-permissions: Permission management
- iOS: FaceUnity frameworks, Agora iOS SDK
- Android: FaceUnity libraries, Agora Android SDK
- State Management: Uses React hooks (useState, useRef, useEffect)
- Resource Management: Utility functions for cross-platform file paths
- Error Handling: Comprehensive error handling for both Agora and FaceUnity
- Add effect bundles to appropriate platform folders
- Update resource loading logic in
loadFaceUnityResources - Add UI controls for new effects
This project is for demonstration purposes. Please ensure you have proper licenses for:
- Agora SDK (check Agora pricing)
- FaceUnity SDK (contact Agora for licensing)
- Agora Documentation: https://docs.agora.io/
- FaceUnity Documentation: Contact Agora support
- React Native: https://reactnative.dev/docs/
-
Required Files:
android/libs/extension_aar-release.aar- FaceUnity native libraries- Assets in
android/app/src/main/assets/- FaceUnity resources
-
Required Code:
loadExtensionProvider('AgoraFaceUnityExtension')- Must call on Android before using FaceUnity
-
Gradle Configuration:
flatDirrepository inandroid/build.gradle- AAR dependency in
android/app/build.gradle
- Fork the repository
- Create a feature branch
- Make your changes
- Test on both iOS and Android (especially Android FaceUnity integration)
- Submit a pull request
Note: You need a valid FaceUnity license to use the beauty and AR features. Contact Agora for licensing information and ensure your license matches your app's package/bundle ID.