Search code examples
react-nativeexpotwiliotwilio-video

`react-native-twilio-video-webrtc` with expo SDK 52 android build error


Here is what i have done

  1. Create a new react-native project with expo sdk 52 and expo router
  2. add react-native-twilio-video-webrtc
  3. Run the command eas build --profile development --platform android

I encounter a gradle build error.

enter image description here

> Task :expo-modules-core:configureCMakeDebug[arm64-v8a]
> Task :app:checkDebugDuplicateClasses FAILED
> Task :app:mergeDebugJavaResource
> Task :expo-av:buildCMakeDebug[arm64-v8a]
> Task :expo-modules-core:buildCMakeDebug[arm64-v8a]
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:checkDebugDuplicateClasses'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
   > Duplicate class android.support.v4.app.INotificationSideChannel found in modules core-1.13.1.aar -> core-1.13.1-runtime (androidx.core:core:1.13.1) and support-compat-27.1.0.aar -> support-compat-27.1.0-runtime (com.android.support:support-compat:27.1.0)
     Duplicate class android.support.v4.app.INotificationSideChannel$Stub found in modules core-1.13.1.aar -> core-1.13.1-runtime (androidx.core:core:1.13.1) and support-compat-27.1.0.aar -> support-compat-27.1.0-runtime (com.android.support:support-compat:27.1.0)
     Duplicate class android.support.v4.app.INotificationSideChannel$Stub$Proxy found in modules core-1.13.1.aar -> core-1.13.1-runtime (androidx.core:core:1.13.1) and support-compat-27.1.0.aar -> support-compat-27.1.0-runtime (com.android.support:support-compat:27.1.0)
     Duplicate class android.support.v4.os.IResultReceiver found in modules core-1.13.1.aar -> core-1.13.1-runtime (androidx.core:core:1.13.1) and support-compat-27.1.0.aar -> support-compat-27.1.0-runtime (com.android.support:support-compat:27.1.0)
    ...

I am happy to dig the issue and try to apply a solution with patch-package but I don't know where to start to debug the problem with react-native-twilio-video-webrtc and how to get more details on the stacktrace.


Solution

  • the solution is quite simple here is the diff

    diff --git a/node_modules/react-native-twilio-video-webrtc/android/build.gradle b/node_modules/react-native-twilio-video-webrtc/android/build.gradle
    index b071b4a..ce8de6b 100644
    --- a/node_modules/react-native-twilio-video-webrtc/android/build.gradle
    +++ b/node_modules/react-native-twilio-video-webrtc/android/build.gradle
    @@ -1,9 +1,8 @@
     apply plugin: 'com.android.library'
     
     def DEFAULT_COMPILE_SDK_VERSION             = 30
    -def DEFAULT_BUILD_TOOLS_VERSION             = "27.0.3"
    +def DEFAULT_BUILD_TOOLS_VERSION             = "30.0.3"
     def DEFAULT_TARGET_SDK_VERSION              = 30
    -def DEFAULT_ANDROID_SUPPORT_VERSION         = "27.1.0"
     def DEFAULT_ANDROID_MIN_SDK_VERSION         = 21
     
     android {
    @@ -31,26 +30,25 @@ android {
         // Specify that we want to split up the APK based on ABI
         splits {
             abi {
    -            // Enable ABI split
                 enable true
    -
    -            // Clear list of ABIs
                 reset()
    -
    -            // Specify each architecture currently supported by the Video SDK
                 include "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
    -
    -            // Specify that we do not want an additional universal SDK
                 universalApk false
             }
         }
     }
     
     dependencies {
    -    def androidSupportVersion = rootProject.hasProperty("androidSupportVersion")  ? rootProject.androidSupportVersion : DEFAULT_ANDROID_SUPPORT_VERSION
    -
         implementation fileTree(dir: 'libs', include: ['*.jar'])
    -    implementation "com.android.support:appcompat-v7:$androidSupportVersion"
    +
    +    // Use AndroidX libraries
    +    implementation "androidx.appcompat:appcompat:1.6.1"
    +    implementation "androidx.core:core:1.13.1"
    +
    +    // Include Twilio Video SDK
         implementation "com.twilio:video-android:7.6.1"
    -    implementation "com.facebook.react:react-native:+"  // From node_modules
    +
    +    // React Native dependency from node_modules
    +    implementation "com.facebook.react:react-native:+"
     }
    +
    diff --git a/node_modules/react-native-twilio-video-webrtc/react-native-twilio-video-webrtc.podspec b/node_modules/react-native-twilio-video-webrtc/react-native-twilio-video-webrtc.podspec
    index b0d7623..6b36197 100644
    --- a/node_modules/react-native-twilio-video-webrtc/react-native-twilio-video-webrtc.podspec
    +++ b/node_modules/react-native-twilio-video-webrtc/react-native-twilio-video-webrtc.podspec
    @@ -19,5 +19,5 @@ Pod::Spec.new do |s|
       s.source_files   = 'ios/*.{h,m}'
     
       s.dependency 'React'
    -  s.dependency 'TwilioVideo', '~> 4.6'
    +  s.dependency 'TwilioVideo', '~> 5.8.3'
     end