I simply had to restart my computer and then it worked again. I didn't have to change anything. It just automatically downloaded a bunch of stuff first:
Starting Gradle Daemon...
Gradle Daemon started in 609 ms
> Task :gradle-plugin:pluginDescriptors
> Task :gradle-plugin:processResources
> Task :gradle-plugin:compileKotlin
> Task :gradle-plugin:compileJava NO-SOURCE
> Task :gradle-plugin:classes
> Task :gradle-plugin:jar
> Task :gradle-plugin:inspectClassesForKotlinIC
> Configure project :app
Reading env from: .env
app: 'annotationProcessor' dependencies won't be recognized as kapt annotation processors. Please change the configuration name to 'kapt' for these artifacts: 'androidx.room:room-compiler:2.6.1'.
> Configure project :react-native-firebase_app
:react-native-firebase_app package.json found at /myproject/node_modules/@react-native-firebase/app/package.json
:react-native-firebase_app:firebase.bom using default value: 32.7.1
:react-native-firebase_app:play.play-services-auth using default value: 20.7.0
:react-native-firebase_app package.json found at /myproject/node_modules/@react-native-firebase/app/package.json
:react-native-firebase_app:version set from package.json: 18.8.0 (18,8,0 - 18008000)
:react-native-firebase_app:android.compileSdk using custom value: 34
:react-native-firebase_app:android.targetSdk using custom value: 34
:react-native-firebase_app:android.minSdk using custom value: 24
:react-native-firebase_app:reactNativeAndroidDir /myproject/node_modules/react-native/android
> Configure project :react-native-firebase_dynamic-links
:react-native-firebase_dynamic-links package.json found at /myproject/node_modules/@react-native-firebase/dynamic-links/package.json
:react-native-firebase_app package.json found at /myproject/node_modules/@react-native-firebase/app/package.json
:react-native-firebase_dynamic-links:firebase.bom using default value: 32.7.1
:react-native-firebase_dynamic-links package.json found at /myproject/node_modules/@react-native-firebase/dynamic-links/package.json
:react-native-firebase_dynamic-links:version set from package.json: 18.8.0 (18,8,0 - 18008000)
:react-native-firebase_dynamic-links:android.compileSdk using custom value: 34
:react-native-firebase_dynamic-links:android.targetSdk using custom value: 34
:react-native-firebase_dynamic-links:android.minSdk using custom value: 24
:react-native-firebase_dynamic-links:reactNativeAndroidDir /myproject/node_modules/react-native/android
> Configure project :react-native-firebase_messaging
:react-native-firebase_messaging package.json found at /myproject/node_modules/@react-native-firebase/messaging/package.json
:react-native-firebase_app package.json found at /myproject/node_modules/@react-native-firebase/app/package.json
:react-native-firebase_messaging:firebase.bom using default value: 32.7.1
:react-native-firebase_messaging package.json found at /myproject/node_modules/@react-native-firebase/messaging/package.json
:react-native-firebase_messaging:version set from package.json: 18.8.0 (18,8,0 - 18008000)
:react-native-firebase_messaging:android.compileSdk using custom value: 34
:react-native-firebase_messaging:android.targetSdk using custom value: 34
:react-native-firebase_messaging:android.minSdk using custom value: 24
:react-native-firebase_messaging:reactNativeAndroidDir /myproject/node_modules/react-native/android
> Task :prepareKotlinBuildScriptModel UP-TO-DATE
Download https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/7.4.2/gradle-7.4.2-sources.jar, took 11 s 400 ms
Download https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.9.0/kotlin-gradle-plugin-1.9.0-sources.jar, took 1 s 628 ms
Download https://repo.maven.apache.org/maven2/de/undercouch/gradle-download-task/4.1.2/gradle-download-task-4.1.2-sources.jar, took 147 ms
...
Download https://dl.google.com/dl/android/maven2/androidx/camera/camera-core/1.3.1/camera-core-1.3.1-sources.jar, took 638 ms
Download https://repo.maven.apache.org/maven2/com/stripe/identity/20.52.3/identity-20.52.3-sources.jar, took 438 ms
Download https://dl.google.com/dl/android/maven2/androidx/databinding/viewbinding/8.5.2/viewbinding-8.5.2-sources.jar, took 304 ms
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.5.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD SUCCESSFUL in 7m 57s
5 actionable tasks: 5 executed