Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I fix React Native app crashing only on real device when upgraded to targetSdk 34?

So i've been working on an app for about a year now, two apps actually, an e-hailing app, a rider and a driver app.

now i'm done and about to post to google play store, google play store won't allow target SDKs less than 34.

My app is built on sdk 33, so i have to change it sdk 34, the problem now is, the app runs on android emulator fine, but not on real device, it crashes instantly with several errors but three major ones

App built with: react-native version : 0.71.12

ERRORS

07-07 08:12:30.518 11330 11330 E SoLoader: couldn't find DSO to load: libjscexecutor.so

07-07 08:12:30.614 11330 11330 E AndroidRuntime: FATAL EXCEPTION: main 07-07 08:12:30.614 11330 11330 E AndroidRuntime: Process: com.roundtripzdriver, PID: 11330 07-07 08:12:30.614 11330 11330 E AndroidRuntime: java.lang.RuntimeException: Unable to create application com.roundtripzdriver.MainApplication: java.lang.RuntimeException: Requested enabled DevSupportManager, but BridgeDevSupportManager class was not found or could not be created

and

07-07 08:12:30.614 11330 11330 E AndroidRuntime: Caused by: java.lang.SecurityException: com.roundtripzdriver: One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts

when i revert to sdk33 it works fine on emulator and on real device

buildscript {
ext {
buildToolsVersion = "33.0.0"
minSdkVersion = 21
compileSdkVersion = 34
targetSdkVersion = 34

// We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
ndkVersion = "23.1.7779620"
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:7.4.2")
classpath("com.facebook.react:react-native-gradle-plugin")
classpath("com.google.gms:google-services:4.3.8")
}
}

the funny thing is this is the exact config i have on the rider app, with the only difference being

the rider app has a lower react-native version of 0.71.4 and in the buildscript.dependencies has a classpath("com.android.tools.build:gradle:7.3.1")

while the driver app (the one crashing) has a higher react native version of 0.71.12 and in the buildscript.dependencies has a classpath("com.android.tools.build:gradle:7.4.2")

I tried changing the classpath of the driver app to fit the rider app, but no change

honestly, I've been on this for a week now, and can't find any solution, I'm at my wits end, so any help would be greatly appreciated.

like image 713
Davies Jeffrey Avatar asked Dec 12 '25 00:12

Davies Jeffrey


1 Answers

Open MainApplication.java and add:

import android.content.BroadcastReceiver;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Build;
import org.jetbrains.annotations.Nullable;
@Override
public Intent registerReceiver(@Nullable BroadcastReceiver receiver, IntentFilter filter) {
    if (Build.VERSION.SDK_INT >= 34 && getApplicationInfo().targetSdkVersion >= 34) {
        return super.registerReceiver(receiver, filter, Context.RECEIVER_EXPORTED);
    } else {
        return super.registerReceiver(receiver, filter);
    }
}

above the oncreate() method. Add this line inside android/app/build.gradle dependencies:

implementation 'org.jetbrains:annotations:16.0.2'
like image 95
Md azeem Avatar answered Dec 14 '25 05:12

Md azeem



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!