Whenever the call is placed on Android 13, it is causing the app to crash. I am using twilio in my react native project. Below is the sentry logs, which I am receiving.

java.lang.IllegalArgumentException: com.myapp.android: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
    at android.app.PendingIntent.checkFlags(PendingIntent.java:408)
    at android.app.PendingIntent.getActivityAsUser(PendingIntent.java:491)
    at android.app.PendingIntent.getActivity(PendingIntent.java:477)
    at android.app.PendingIntent.getActivity(PendingIntent.java:441)
    at com.hoxfon.react.RNTwilioVoice.CallNotificationManager.createHangupNotification(CallNotificationManager.java:154)
    at com.hoxfon.react.RNTwilioVoice.TwilioVoiceModule$3.onConnected(TwilioVoiceModule.java:309)
    at com.twilio.voice.Call$1$2.run(Call.java:641)
    at android.os.Handler.handleCallback(Handler.java:942)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:226)
    at android.os.Looper.loop(Looper.java:313)
    at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:226)
    at java.lang.Thread.run(Thread.java:1012)

My android/build.gradle looks like

buildscript {
    ext {
        buildToolsVersion = "30.0.2"
        minSdkVersion = 21
        compileSdkVersion = 31
        targetSdkVersion = 31
        ndkVersion = "21.4.7075529"
        androidXCore = "1.7.0"
        // supportLibVersion = "xxx"
        playServicesVersion = "18.0.1" // or find latest version
        androidMapsUtilsVersion = "2.3.0"
        playCoreVersion = '1.10.3'
        googlePlayServicesAuthVersion = "20.1.0" // for google auth
        kotlinVersion = '1.5.0' // for audio palyer
    }
    repositories {
        google()
        mavenCentral()
        // maven { url 'https://plugins.gradle.org/m2/' }
    }
    dependencies {
        classpath('com.android.tools.build:gradle:7.0.4')
        // classpath('com.getkeepsafe.relinker:relinker:1.2.2') // added for twilio
        classpath('com.google.gms:google-services:4.3.10')
        classpath('com.google.firebase:firebase-messaging:23.1.1') //old 21.0.1
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" // for audio player
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
    project.ext {
        excludeAppGlideModule = true
    }
}

Have already tried adding these in my android/app/build.gradle but it didn't work.

implementation 'androidx.work:work-runtime:2.7.1' //androidx.work:work-runtime:2.7.0-alpha05
    implementation 'androidx.work:work-runtime-ktx:2.7.1' 
    configurations.all {
        resolutionStrategy { 
            force 'androidx.work:work-runtime:2.7.1'
            force 'androidx.work:work-runtime-ktx:2.7.1' 
        }
    }

Any help would be really appreciated. My versions for dependencies are also mentioned below

 "react": "17.0.2",
 "react-native": "0.66.1",
 "react-native-twilio-programmable-voice": "github:hoxfon/react-native-twilio-programmable-voice#feat/twilio-android-sdk-5",
"@react-native-firebase/app": "^14.3.0",
 "@react-native-firebase/messaging": "^14.3.0",
 "react-native-audio-recorder-player": "^3.3.4",
0

There are 0 best solutions below