I’m upgrading my targetSdkVersion to 34
buildscript {
ext {
buildToolsVersion = "29.0.3"
minSdkVersion = 26
compileSdkVersion = 33
targetSdkVersion = 34
supportLibVersion = 34
}
and I’ve run into this error when running the react-native app.
I’ve seen a lot of solutions online that suggest adding
context.registerReceiver(broadcastReceiver, intentFilter, RECEIVER_EXPORTED);
But they don’t mention where it needs to be added. I’ve only worked on the react-native side so it would help if I had more details about the Android specific updates.
2
Answers
I added the following to
MainApplication.java
file.and before
public void onCreate()
in the same file,In
android/build.gradle
under dependenciesIn
android/gradle/wrapper/gradle-wrapper.properties
I also kept getting the error
couldn't find DSO to load: libhermes.so
For which I had to upgrade
react-native-reanimated
to 3.5.4.I also upgraded my
react-native-screens
to3.22.0
.My other main library versions
This fixed things for me
What I did to solve this is that I opened up the node_modules for my React Native project (
code node_modules
) and I searched for all the occurences ofregisterReceiver
. Then I looked at the libraries in the search findings and like that I knew which libraries I have to upgrade. Most libs already made a release to support SDK 34, but I also found libs that did not: for these libs I used a patch-package to create a patch file where I added the corresponding flag myself to theregisterReceiver
call(s).