Unable to compile for Android

This library won’t compile in my project. The only way I can make it compile is by removing the line:
.setForegroundServiceBehavior(NotificationCompat.FOREGROUND_SERVICE_IMMEDIATE);
in MediaProjectionNotification.java

Error message:

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
C:\Users\project\node_modules\react-native-webrtc\android\src\main\java\com\oney\WebRTCModule\MediaProjectionNotification.java:74: error: cannot find symbol
                .setForegroundServiceBehavior(NotificationCompat.FOREGROUND_SERVICE_IMMEDIATE);

react-native: 0.68.2
react-native-webrtc: 118.0.7

~/android/build.gradle

buildscript {
    ext {
        buildToolsVersion = "31.0.0"
        minSdkVersion = 23
        compileSdkVersion = 33
        targetSdkVersion = 33

        if (System.properties['os.arch'] == "aarch64") {
            // For M1 Users we need to use the NDK 24 which added support for aarch64
            ndkVersion = "24.0.8215888"
        } else {
            // Otherwise we default to the side-by-side NDK version from AGP.
            ndkVersion = "21.4.7075529"
        }
    }

I followed the readme instructions found here

Let me know if I need to post additional info

Bump. This error still persists in react-native-webrtc ^124.0.0.

I attempted to create a react-native project from scratch running react-native version 0.74.2, then installing react-native-webrtc ^124.0.0 and it does not throw this error when building. I’m guessing it has something to do with the build tooling (gradle, SDK, Java, etc…), however it seems not to be documented anywhere so for anyone using an older version of react-native running into this issue:

  • Try to your react native project and their dependencies

If that doesn’t work, and you don’t require the screen sharing functionality of react-native-webrtc, remove the line:
.setForegroundServiceBehavior(NotificationCompat.FOREGROUND_SERVICE_IMMEDIATE);
in MediaProjectionNotification.java