Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App Crashes - On upgrading to Android 14(SDK 34) #41288

Closed
ShaminiSaravanan opened this issue Nov 2, 2023 · 185 comments
Closed

App Crashes - On upgrading to Android 14(SDK 34) #41288

ShaminiSaravanan opened this issue Nov 2, 2023 · 185 comments

Comments

@ShaminiSaravanan
Copy link

Description

Currently, my codebase supports Android 13 (SDK version: 33). I wanted to upgrade to SDK 33(Android 14)

On Android 14 updates, the following changes have been made:

kotlinVersion = "1.6.0"
buildToolsVersion = "34.0.0"
minSdkVersion = 23
compileSdkVersion = 34
targetSdkVersion = 34

My current React Native version is 0.70.8.

However, upon launching the application, I encountered an issue where the App Crashes immediately on the launch. To investigate this, I pulled a Bug Report, which provided the following insights:

  1. Caused by: java.lang.RuntimeException: Requested enabled DevSupportManager, but BridgeDevSupportManager class was not found or could not be created.
  2. Caused by: java.lang.SecurityException: : One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts.
  3. Caused by: java.lang.reflect.InvocationTargetException.
  4. Caused by: android.os.RemoteException: Remote stack trace.

React Native Version

0.70.8

Output of npx react-native info

System:
OS: macOS 14.0
CPU: (8) arm64 Apple M1
Memory: 65.91 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.4.0 - /opt/homebrew/bin/node
Yarn: 1.22.19 - /opt/homebrew/bin/yarn
npm: 9.8.1 - /opt/homebrew/bin/npm
Watchman: 2023.07.10.00 - /opt/homebrew/bin/watchman
Managers:
CocoaPods: 1.13.0 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 23.0, iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0
Android SDK: Not Found
IDEs:
Android Studio: 2022.3 AI-223.8836.35.2231.10406996
Xcode: 15.0.1/15A507 - /usr/bin/xcodebuild
Languages:
Java: 11.0.19 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 18.1.0 => 18.1.0
react-native: 0.70.8 => 0.70.8
react-native-macos: Not Found
npmGlobalPackages:
react-native: Not Found

Steps to reproduce

Update Build.gradle's version to support SDK version 34.

Snack, screenshot, or link to a repository

Build.gradle file: https://snack.expo.dev/@shaminisaravanan/android14

Copy link

github-actions bot commented Nov 2, 2023

⚠️ Newer Version of React Native is Available!
ℹ️ You are on a supported minor version, but it looks like there's a newer patch available - 0.70.14. Please upgrade to the highest patch for your minor or latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If it does not repro, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the most recent releases.

@github-actions github-actions bot added the Platform: Android Android applications. label Nov 2, 2023
@ShaminiSaravanan
Copy link
Author

I wanted to stick with React Version 0.70.8, as my code runs for both Android and iOS.

In my project, 0.70.8 is compatible for both iOS and Android

@cipolleschi
Copy link
Contributor

Thanks for the issue. Consider that, as soon as we will release 0.73 as stable (ETA: end Nov/start Dec) we are not going to support 0.70 anymore. Hopefully, this gives you some time to plan the migration to the latest version.

@ShaminiSaravanan
Copy link
Author

Hi there! 👋

I'm still experiencing the problem, and any guidance or suggestions would be greatly appreciated. If there's any additional information I can provide to help with debugging or if there's a specific way you'd like me to test something, please let me know.

Thank you in advance for your time and assistance!

@cipolleschi
Copy link
Contributor

Have a look at this conversation: reactwg/react-native-releases#84 (comment)

We tried to add support for new version of Android in 0.70, but that's not possible unfortunately.
If you need to support new Android SDK and Android 14, you have to update to a newer version of React Native.

@rakeshkumar217
Copy link

Hi cipolleschi, here i am using recent version of react-native(72.6) and android target version 34. But i am still facing the same issue.
I have found one solution related to RECEIVER_NOT_EXPORTED and I have applied check for android 14(34).
Link: https://stackoverflow.com/questions/77235063/one-of-receiver-exported-or-receiver-not-exported-should-be-specified-when-a-rec
But still have same issue. I don't how to get out of this problem.

@cipolleschi
Copy link
Contributor

Can you provide a reproducer so we can investigate what's going on?

@zkteco-home
Copy link

zkteco-home commented Dec 6, 2023

I upgraded to 0.73 from RN0.72.7 and android sdk 34,encountered an issue where the App Crashes immediately on the launch

@cortinico
Copy link
Contributor

encountered an issue where the App Crashes immediately on the launch. To investigate this, I pulled a Bug Report, which provided the following insights:

  1. Caused by: java.lang.RuntimeException: Requested enabled DevSupportManager, but BridgeDevSupportManager class was not found or could not be created.

I'm closing this issue as related to React Native 0.70 (which is no longer supported).
The author hasn't provided a reproducer also.

@zkteco-home please open a new issue

@yogendrajs
Copy link

I'm also facing this now, any update on this?

@bekazandukeli
Copy link

bekazandukeli commented Feb 15, 2024

Removing minifyEnabled true for debug config from android/app/build.gradle fixed the issue.
(For me, the debug build was crashing only, not the release one).

@anhquan291
Copy link

anhquan291 commented Feb 27, 2024

Hi @zkteco-home @rakeshkumar217 , have you managed to fix this issue? I'm still facing it after patching the DevSupportManagerBase.java!
Thank you

@zkteco-home
Copy link

in my side,working fine

@anhquan291
Copy link

@zkteco-home which version of RN is your project on?
I upgraded to 0.73 from RN0.72.7 and android sdk 34,encountered an issue where the App Crashes immediately on the launch
How about your comment above bro?
Thank you

@zkteco-home
Copy link

when 0.73 just released,I also met same problem,if just change RN version,it is wrong,bcz android folder part files changed,so I suggest that you create new project with RN 0.73,copy your code to new project ,or replace android folder with new android

@anhquan291
Copy link

@zkteco-home thank you 🙏

@AftabUfaq
Copy link

i have the same issue after i have added kotlin 1.6.0 . after that i ahve removed it but have same issue.

@zahitesh
Copy link

zahitesh commented Mar 5, 2024

I had the same issue with my app running on React Native v0.67.4
I've published a blog how I patch this version of React Native to support Android 14 (SDK 34)
https://medium.com/@zahitesh/android-14-sdk-34-support-for-react-native-ver-0-69-x-2554f4dc937d

@hoangdoanfinx
Copy link

@zahitesh how can we create .aar file without hermes? In my Project, I disabled Hermes build so I cannot run ./gradlew ReactAndroid:installArchives. Thank you so much.

@hansrajshokal
Copy link

@hoangdoanfinx did you get any solution for this?

@tofujlg
Copy link

tofujlg commented Apr 8, 2024

@zahitesh
Your blog post seemed to be very useful but I'm using "react-native": "0.71.8" and react-native > 71 does not contain /android and we cannot use that trick :(

@valentin-wristcheck
Copy link

I had to upgrade to react-native latest version to fix this issue on my side.
This tool helped me quite a lot to do the migration based on whatever version i was on before, would highly recommend to use it: https://react-native-community.github.io/upgrade-helper/. I still had to update some of the packages that we use in our app in order for the app to be working once migrated.

@yogendrajs
Copy link

yogendrajs commented Apr 8, 2024 via email

@SarjuHansaliya
Copy link

and then update the code as top solution above?

yes @marcell6 Then based on the libraries you are using you need to check 2 things.

  1. If registerReceiver statement already wrapped with SDK 34 condition then you dont need to change anything for that library
  2. If registerReceiver is not wrapped with SDK 34 condition then check
    1. If new version of library available with fixes then upgrade to that version.
    2. If no new update available then you may need to patch the library using patch-package

@gkasireddy202
Copy link

I updated the targetSdkVersion to 34 in my project(MyProject>android>build.gradle). I tested the app functionality on a Pixel 8 device has Android version 14. I did not face any crashes in the app and everything works well.
Can I update libraries or not before pushing the app to the Play Store?

ext {
buildToolsVersion = "34.0.0"
minSdkVersion = 26
compileSdkVersion = 34
targetSdkVersion = 34
ndkVersion = "25.1.8937393"
kotlinVersion = "1.8.0"
}

@kunal-kudale-invimatic
Copy link

I am using react-native 0.62.3, due to some reasons I cannot upgrade my react-native version. After updating my sdk version to 34 and doing changes in mainapplication.java. I am getting error for "Context.RECEIVER_EXPORTED".

My MainApplication.java

package guru.fan.invimaticconvention;

import android.app.Application;
import android.content.Context;

import com.bugsnag.BugsnagReactNative;
import com.crashlytics.android.Crashlytics;
import com.facebook.CallbackManager;
import com.facebook.drawee.backends.pipeline.Fresco;
import com.facebook.react.PackageList;
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactInstanceManager;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.soloader.SoLoader;
import com.sudoplz.reactnativeamplitudeanalytics.RNAmplitudeSDKPackage;

import java.lang.reflect.InvocationTargetException;
import java.util.List;

import guru.fan.invimaticconvention.pdf.PdfViewPackage;
import io.branch.referral.Branch;
import io.fabric.sdk.android.Fabric;
//import io.invertase.firebase.RNFirebasePackage;
//import io.invertase.firebase.analytics.RNFirebaseAnalyticsPackage;
//import io.invertase.firebase.instanceid.RNFirebaseInstanceIdPackage;
//import io.invertase.firebase.messaging.RNFirebaseMessagingPackage;
//import io.invertase.firebase.notifications.RNFirebaseNotificationsPackage;
//import io.invertase.firebase.perf.RNFirebasePerformancePackage;
import android.content.BroadcastReceiver;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Build;
import org.jetbrains.annotations.Nullable;

public class MainApplication extends Application implements ReactApplication {

private static CallbackManager mCallbackManager = CallbackManager.Factory.create();

protected static CallbackManager getCallbackManager() {
return mCallbackManager;
}

private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {

@Override
public boolean getUseDeveloperSupport() {
  return BuildConfig.DEBUG;
}

@Override
protected List<ReactPackage> getPackages() {
  @SuppressWarnings("UnnecessaryLocalVariable")
  List<ReactPackage> packages = new PackageList(this).getPackages();
  packages.add(new RNAmplitudeSDKPackage(MainApplication.this));

// packages.add(new RNFirebaseNotificationsPackage());
// packages.add(new RNFirebaseMessagingPackage());
// packages.add(new RNFirebaseAnalyticsPackage());
// packages.add(new RNFirebasePerformancePackage());
// packages.add(new RNFirebaseInstanceIdPackage());
packages.add(new PdfViewPackage());
return packages;
}

@Override
protected String getJSMainModuleName() {
  return "index";
}

};

@OverRide
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}

@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);
}
}

@OverRide
public void onCreate() {
super.onCreate();
Fresco.initialize(this);
Fabric.with(this, new Crashlytics());
Branch.getAutoInstance(this);
BugsnagReactNative.start(this);
SoLoader.init(this, /* native exopackage */ false);
initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
}

/**

  • Loads Flipper in React Native templates. Call this in the onCreate method with something like
  • initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
  • @param context
  • @param reactInstanceManager
    /
    private static void initializeFlipper(
    Context context, ReactInstanceManager reactInstanceManager) {
    if (BuildConfig.DEBUG) {
    try {
    /

    We use reflection here to pick up the class that initializes Flipper,
    since Flipper library is not available in release mode
    */
    Class<?> aClass = Class.forName("com.rndiffapp.ReactNativeFlipper");
    aClass
    .getMethod("initializeFlipper", Context.class, ReactInstanceManager.class)
    .invoke(null, context, reactInstanceManager);
    } catch (ClassNotFoundException e) {
    e.printStackTrace();
    } catch (NoSuchMethodException e) {
    e.printStackTrace();
    } catch (IllegalAccessException e) {
    e.printStackTrace();
    } catch (InvocationTargetException e) {
    e.printStackTrace();
    }
    }
    }
    }

My app/build.gradle
def nodeModules = "$rootDir/../../../node_modules"

apply plugin: "com.android.application"
apply plugin: 'io.fabric'
// apply plugin: "com.google.firebase.firebase-perf"

repositories {
maven { url 'https://maven.fabric.io/public' }
google()
}

import com.android.build.OutputFile
//import com.google.gms.googleservices.GoogleServicesPlugin

/**

  • The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
  • and bundleReleaseJsAndAssets).
  • These basically call react-native bundle with the correct arguments during the Android build
  • cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
  • bundle directly from the development server. Below you can see all the possible configurations
  • and their defaults. If you decide to add a configuration block, make sure to add it before the
  • apply from: "../../node_modules/react-native/react.gradle" line.
  • project.ext.react = [
  • // the name of the generated asset file containing your JS bundle
  • bundleAssetName: "index.android.bundle",
  • // the entry file for bundle generation. If none specified and
  • // "index.android.js" exists, it will be used. Otherwise "index.js" is
  • // default. Can be overridden with ENTRY_FILE environment variable.
  • entryFile: "index.android.js",
  • // whether to bundle JS and assets in debug mode
  • bundleInDebug: false,
  • // whether to bundle JS and assets in release mode
  • bundleInRelease: true,
  • // whether to bundle JS and assets in another build variant (if configured).
  • // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
  • // The configuration property can be in the following formats
  • // 'bundleIn${productFlavor}${buildType}'
  • // 'bundleIn${buildType}'
  • // bundleInFreeDebug: true,
  • // bundleInPaidRelease: true,
  • // bundleInBeta: true,
  • // whether to disable dev mode in custom build variants (by default only disabled in release)
  • // for example: to disable dev mode in the staging build type (if configured)
  • devDisabledInStaging: true,
  • // The configuration property can be in the following formats
  • // 'devDisabledIn${productFlavor}${buildType}'
  • // 'devDisabledIn${buildType}'
  • // the root of your project, i.e. where "package.json" lives
  • root: "../../",
  • // where to put the JS bundle asset in debug mode
  • jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
  • // where to put the JS bundle asset in release mode
  • jsBundleDirRelease: "$buildDir/intermediates/assets/release",
  • // where to put drawable resources / React Native assets, e.g. the ones you use via
  • // require('./image.png')), in debug mode
  • resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
  • // where to put drawable resources / React Native assets, e.g. the ones you use via
  • // require('./image.png')), in release mode
  • resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
  • // by default the gradle tasks are skipped if none of the JS files or assets change; this means
  • // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
  • // date; if you have any other folders that you want to ignore for performance reasons (gradle
  • // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
  • // for example, you might want to remove it from here.
  • inputExcludes: ["android/", "ios/"],
  • // override which node gets called and with what additional arguments
  • nodeExecutableAndArgs: ["node"],
  • // supply additional arguments to the packager
  • extraPackagerArgs: []
  • ]
    */

project.ext.react = [
enableHermes: false,
hermesCommand: "$nodeModules/hermesvm/%OS-BIN%/hermes",
]

apply from: "$nodeModules/react-native/react.gradle"

/**

  • Set this to true to create two separate APKs instead of one:
    • An APK that only works on ARM devices
    • An APK that only works on x86 devices
  • The advantage is the size of the APK is reduced by about 4MB.
  • Upload all the APKs to the Play Store and people will download
  • the correct one based on the CPU architecture of their device.
    */
    def enableSeparateBuildPerCPUArchitecture = false

/**

  • Run Proguard to shrink the Java bytecode in release builds.
    */
    def enableProguardInReleaseBuilds = false

/**

  • The preferred build flavor of JavaScriptCore.
  • For example, to use the international variant, you can use:
  • def jscFlavor = 'org.webkit:android-jsc-intl:+'
  • The international variant includes ICU i18n library and necessary data
  • allowing to use e.g. Date.toLocaleString and String.localeCompare that
  • give correct results when using with locales other than en-US. Note that
  • this variant is about 6MiB larger per architecture than default.
    /
    def jscFlavor = 'org.webkit:android-jsc-intl:+'
    // def jscFlavor = 'org.webkit:android-jsc:+'
    /
    *
  • Whether to enable the Hermes VM.
  • This should be set on project.ext.react and mirrored here. If it is not set
  • on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
  • and the benefits of using Hermes will therefore be sharply reduced.
    */
    def enableHermes = project.ext.react.get("enableHermes", false);

android {
//https://github.com/wonday/react-native-pdf#installation
packagingOptions {
pickFirst '/x86/libc++_shared.so'
pickFirst '
/x86_64/libjsc.so'
pickFirst '/arm64-v8a/libjsc.so'
pickFirst '
/arm64-v8a/libc++_shared.so'
pickFirst '/x86_64/libc++_shared.so'
pickFirst '
/armeabi-v7a/libc++_shared.so'
pickFirst '/x86/libjsc.so'
pickFirst '
/armeabi-v7a/libjsc.so'
}

compileSdkVersion rootProject.ext.compileSdkVersion

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

sourceSets.main {
    jni.srcDirs = []
}

defaultConfig {
    applicationId "guru.fan.invimaticconvention"
    minSdkVersion rootProject.ext.minSdkVersion
    targetSdkVersion rootProject.ext.targetSdkVersion
    multiDexEnabled true
    versionCode 314
    versionName "2.23.98"

    ndk {
        abiFilters 'armeabi-v7a','arm64-v8a','x86','x86_64'
    }
    // Add these lines below the existing config
    renderscriptTargetApi 23
    renderscriptSupportModeEnabled true
    vectorDrawables.useSupportLibrary = true

    testBuildType System.getProperty('testBuildType', 'debug')  // This will later be used to control the test apk build type
    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

    resConfigs "en"

    // https://react-native-iap.dooboolab.com/docs/installing
    missingDimensionStrategy 'store', 'play'
}
signingConfigs {
    release {
        if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
            storeFile file(MYAPP_RELEASE_STORE_FILE)
            storePassword MYAPP_RELEASE_STORE_PASSWORD
            keyAlias MYAPP_RELEASE_KEY_ALIAS
            keyPassword MYAPP_RELEASE_KEY_PASSWORD
        }
    }
}
splits {
    abi {
        reset()
        enable enableSeparateBuildPerCPUArchitecture
        universalApk false  // If true, also generate a universal APK
        include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
    }
}
buildTypes {
    release {
        minifyEnabled enableProguardInReleaseBuilds
        proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        signingConfig signingConfigs.release
    }
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
    variant.outputs.each { output ->
        // For each separate APK per architecture, set a unique version code as described here:
        // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
        def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
        def abi = output.getFilter(OutputFile.ABI)
        if (abi != null) {  // null for the universal-debug, universal-release variants
            output.versionCodeOverride =
                    versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
        }
        // apk name should be like: fanguru-app-1.0
        // update defaultConfig versionName name to this to work fine
        //output.outputFile = new File(output.outputFile.parent,
        //        "guru-fan-app-${variant.versionName}.apk")
    }
}
dexOptions {
    javaMaxHeapSize "4g"
    preDexLibraries = false
}
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

}

android {
defaultConfig {
multiDexEnabled true
missingDimensionStrategy 'react-native-camera', 'general'
testBuildType System.getProperty('testBuildType', 'debug') // This will later be used to control the test apk build type
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}

}

crashlytics {
enableNdk false
}

dependencies {
if (enableHermes) {
def hermesPath = "$nodeModules/hermes-engine/android/";
debugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
implementation jscFlavor
}

def multidex_version = "2.0.1"                                  //Line added to resolve error while creating apk/aab
implementation "androidx.multidex:multidex:$multidex_version"   //Line added to resolve error while creating apk/aab

implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "com.android.billingclient:billing:5.0.0"
implementation 'com.facebook.react:react-native'

// https://github.com/SudoPlz/react-native-amplitude-analytics#android-manual-installation
implementation 'com.amplitude:android-sdk:2.19.1' // native sdk of amplitude
implementation project(':react-native-amplitude-analytics')

// Firebase dependencies
// https://rnfirebase.io/docs/v5.x.x/installation/android#3.-Add-Firebase-modules
// implementation project(':react-native-firebase')
// implementation "com.google.android.gms:play-services-base:17.0.1"
// implementation "com.google.firebase:firebase-core:16.0.9"
implementation "com.google.firebase:firebase-messaging:18.0.0"
// implementation "com.google.firebase:firebase-perf:17.0.2"
// implementation 'com.google.firebase:firebase-inappmessaging-display:17.2.0'

// For animated GIF support
// https://frescolib.org/docs/index.html
implementation 'com.facebook.fresco:fresco:2.0.0'
implementation 'com.facebook.fresco:animated-gif:2.0.0'
implementation 'com.android.support:support-core-utils:24.2.1'

implementation 'com.android.support:exifinterface:27.+'

// implementation('com.facebook.android:facebook-android-sdk:[5,6)') {
//     exclude group: 'com.parse.bolts', module: 'bolts-android';
//     exclude group: 'com.parse.bolts', module: 'bolts-applinks';
//     exclude group: 'com.parse.bolts', module: 'bolts-tasks';
// }
implementation 'com.facebook.android:facebook-android-sdk:4.26.0'

// For Detox tests
androidTestImplementation('com.wix:detox:+') { transitive = true } 
androidTestImplementation 'junit:junit:4.12'

// From node_modules
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation('com.crashlytics.sdk.android:crashlytics:2.9.0@aar') {
    transitive = true;
}
implementation 'com.google.android.exoplayer:exoplayer:2.7.1'

// coroutines!
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.2'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.2'

// for PDF viewer
implementation 'com.otaliastudios:zoomlayout:1.7.0'

    implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
implementation 'com.google.android.gms:play-services-maps:17.0.0'
implementation 'com.facebook.soloader:soloader:0.11.0+'
implementation 'org.jetbrains:annotations:16.0.2'


debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
  exclude group:'com.facebook.fbjni'
}
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
    exclude group:'com.facebook.flipper'

    // https://stackoverflow.com/questions/60926425/java-lang-runtimeexception-requested-enabled-devsupportmanager-but-devsupportm
    exclude group:'com.squareup.okhttp3', module:'okhttp'
}
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
    exclude group:'com.facebook.flipper'
}

}

configurations.all { // fixes a Detox dependency
resolutionStrategy {
force 'androidx.annotation:annotation:1.0.2'
}
}

// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}

project.ext.vectoricons = [
iconFontNames: [ 'MaterialIcons.ttf', 'MaterialCommunityIcons.ttf', 'Entypo.ttf' ] // Name of the font files you want to copy
]

apply from: file("$nodeModules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
apply from: "$nodeModules/react-native-vector-icons/fonts.gradle"

apply plugin: 'kotlin-android'

// this should be last
// https://rnfirebase.io/docs/v5.x.x/installation/android#2.-Setup-google-services.json
apply plugin: 'com.google.gms.google-services'

// fixes dependency resolution error
// invertase/react-native-firebase#1155 (comment)
// GoogleServicesPlugin.config.disableVersionCheck = true

Please let me know if any solution.

@kunal-kudale-invimatic
Copy link

I am using react-native 0.62.3, due to some reasons I cannot upgrade my react-native version. After updating my sdk version to 34 and doing changes in mainapplication.java. I am getting error for "Context.RECEIVER_EXPORTED".

My MainApplication.java

package guru.fan.invimaticconvention;

import android.app.Application; import android.content.Context;

import com.bugsnag.BugsnagReactNative; import com.crashlytics.android.Crashlytics; import com.facebook.CallbackManager; import com.facebook.drawee.backends.pipeline.Fresco; import com.facebook.react.PackageList; import com.facebook.react.ReactApplication; import com.facebook.react.ReactInstanceManager; import com.facebook.react.ReactNativeHost; import com.facebook.react.ReactPackage; import com.facebook.soloader.SoLoader; import com.sudoplz.reactnativeamplitudeanalytics.RNAmplitudeSDKPackage;

import java.lang.reflect.InvocationTargetException; import java.util.List;

import guru.fan.invimaticconvention.pdf.PdfViewPackage; import io.branch.referral.Branch; import io.fabric.sdk.android.Fabric; //import io.invertase.firebase.RNFirebasePackage; //import io.invertase.firebase.analytics.RNFirebaseAnalyticsPackage; //import io.invertase.firebase.instanceid.RNFirebaseInstanceIdPackage; //import io.invertase.firebase.messaging.RNFirebaseMessagingPackage; //import io.invertase.firebase.notifications.RNFirebaseNotificationsPackage; //import io.invertase.firebase.perf.RNFirebasePerformancePackage; import android.content.BroadcastReceiver; import android.content.Intent; import android.content.IntentFilter; import android.os.Build; import org.jetbrains.annotations.Nullable;

public class MainApplication extends Application implements ReactApplication {

private static CallbackManager mCallbackManager = CallbackManager.Factory.create();

protected static CallbackManager getCallbackManager() { return mCallbackManager; }

private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {

@Override
public boolean getUseDeveloperSupport() {
  return BuildConfig.DEBUG;
}

@Override
protected List<ReactPackage> getPackages() {
  @SuppressWarnings("UnnecessaryLocalVariable")
  List<ReactPackage> packages = new PackageList(this).getPackages();
  packages.add(new RNAmplitudeSDKPackage(MainApplication.this));

// packages.add(new RNFirebaseNotificationsPackage()); // packages.add(new RNFirebaseMessagingPackage()); // packages.add(new RNFirebaseAnalyticsPackage()); // packages.add(new RNFirebasePerformancePackage()); // packages.add(new RNFirebaseInstanceIdPackage()); packages.add(new PdfViewPackage()); return packages; }

@Override
protected String getJSMainModuleName() {
  return "index";
}

};

@OverRide public ReactNativeHost getReactNativeHost() { return mReactNativeHost; }

@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); } }

@OverRide public void onCreate() { super.onCreate(); Fresco.initialize(this); Fabric.with(this, new Crashlytics()); Branch.getAutoInstance(this); BugsnagReactNative.start(this); SoLoader.init(this, /* native exopackage */ false); initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); }

/**

  • Loads Flipper in React Native templates. Call this in the onCreate method with something like
  • initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
  • @param context
  • @param reactInstanceManager
    /
    private static void initializeFlipper(
    Context context, ReactInstanceManager reactInstanceManager) {
    if (BuildConfig.DEBUG) {
    try {
    /

    We use reflection here to pick up the class that initializes Flipper,
    since Flipper library is not available in release mode
    */
    Class<?> aClass = Class.forName("com.rndiffapp.ReactNativeFlipper");
    aClass
    .getMethod("initializeFlipper", Context.class, ReactInstanceManager.class)
    .invoke(null, context, reactInstanceManager);
    } catch (ClassNotFoundException e) {
    e.printStackTrace();
    } catch (NoSuchMethodException e) {
    e.printStackTrace();
    } catch (IllegalAccessException e) {
    e.printStackTrace();
    } catch (InvocationTargetException e) {
    e.printStackTrace();
    }
    }
    }
    }

My app/build.gradle def nodeModules = "$rootDir/../../../node_modules"

apply plugin: "com.android.application" apply plugin: 'io.fabric' // apply plugin: "com.google.firebase.firebase-perf"

repositories { maven { url 'https://maven.fabric.io/public' } google() }

import com.android.build.OutputFile //import com.google.gms.googleservices.GoogleServicesPlugin

/**

  • The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
  • and bundleReleaseJsAndAssets).
  • These basically call react-native bundle with the correct arguments during the Android build
  • cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
  • bundle directly from the development server. Below you can see all the possible configurations
  • and their defaults. If you decide to add a configuration block, make sure to add it before the
  • apply from: "../../node_modules/react-native/react.gradle" line.
  • project.ext.react = [
  • // the name of the generated asset file containing your JS bundle
  • bundleAssetName: "index.android.bundle",
  • // the entry file for bundle generation. If none specified and
  • // "index.android.js" exists, it will be used. Otherwise "index.js" is
  • // default. Can be overridden with ENTRY_FILE environment variable.
  • entryFile: "index.android.js",
  • // whether to bundle JS and assets in debug mode
  • bundleInDebug: false,
  • // whether to bundle JS and assets in release mode
  • bundleInRelease: true,
  • // whether to bundle JS and assets in another build variant (if configured).
  • // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
  • // The configuration property can be in the following formats
  • // 'bundleIn${productFlavor}${buildType}'
  • // 'bundleIn${buildType}'
  • // bundleInFreeDebug: true,
  • // bundleInPaidRelease: true,
  • // bundleInBeta: true,
  • // whether to disable dev mode in custom build variants (by default only disabled in release)
  • // for example: to disable dev mode in the staging build type (if configured)
  • devDisabledInStaging: true,
  • // The configuration property can be in the following formats
  • // 'devDisabledIn${productFlavor}${buildType}'
  • // 'devDisabledIn${buildType}'
  • // the root of your project, i.e. where "package.json" lives
  • root: "../../",
  • // where to put the JS bundle asset in debug mode
  • jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
  • // where to put the JS bundle asset in release mode
  • jsBundleDirRelease: "$buildDir/intermediates/assets/release",
  • // where to put drawable resources / React Native assets, e.g. the ones you use via
  • // require('./image.png')), in debug mode
  • resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
  • // where to put drawable resources / React Native assets, e.g. the ones you use via
  • // require('./image.png')), in release mode
  • resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
  • // by default the gradle tasks are skipped if none of the JS files or assets change; this means
  • // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
  • // date; if you have any other folders that you want to ignore for performance reasons (gradle
  • // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
  • // for example, you might want to remove it from here.
  • inputExcludes: ["android/", "ios/"],
  • // override which node gets called and with what additional arguments
  • nodeExecutableAndArgs: ["node"],
  • // supply additional arguments to the packager
  • extraPackagerArgs: []
  • ]
    */

project.ext.react = [ enableHermes: false, hermesCommand: "$nodeModules/hermesvm/%OS-BIN%/hermes", ]

apply from: "$nodeModules/react-native/react.gradle"

/**

  • Set this to true to create two separate APKs instead of one:
    • An APK that only works on ARM devices
    • An APK that only works on x86 devices
  • The advantage is the size of the APK is reduced by about 4MB.
  • Upload all the APKs to the Play Store and people will download
  • the correct one based on the CPU architecture of their device.
    */
    def enableSeparateBuildPerCPUArchitecture = false

/**

  • Run Proguard to shrink the Java bytecode in release builds.
    */
    def enableProguardInReleaseBuilds = false

/**

  • The preferred build flavor of JavaScriptCore.
  • For example, to use the international variant, you can use:
  • def jscFlavor = 'org.webkit:android-jsc-intl:+'
  • The international variant includes ICU i18n library and necessary data
  • allowing to use e.g. Date.toLocaleString and String.localeCompare that
  • give correct results when using with locales other than en-US. Note that
  • this variant is about 6MiB larger per architecture than default.
    /
    def jscFlavor = 'org.webkit:android-jsc-intl:+'
    // def jscFlavor = 'org.webkit:android-jsc:+'
    /
    *
  • Whether to enable the Hermes VM.
  • This should be set on project.ext.react and mirrored here. If it is not set
  • on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
  • and the benefits of using Hermes will therefore be sharply reduced.
    */
    def enableHermes = project.ext.react.get("enableHermes", false);

android { //https://github.com/wonday/react-native-pdf#installation packagingOptions { pickFirst '/x86/libc++_shared.so' pickFirst '/x86_64/libjsc.so' pickFirst '/arm64-v8a/libjsc.so' pickFirst '/arm64-v8a/libc++_shared.so' pickFirst '/x86_64/libc++_shared.so' pickFirst '/armeabi-v7a/libc++_shared.so' pickFirst '/x86/libjsc.so' pickFirst '/armeabi-v7a/libjsc.so' }

compileSdkVersion rootProject.ext.compileSdkVersion

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

sourceSets.main {
    jni.srcDirs = []
}

defaultConfig {
    applicationId "guru.fan.invimaticconvention"
    minSdkVersion rootProject.ext.minSdkVersion
    targetSdkVersion rootProject.ext.targetSdkVersion
    multiDexEnabled true
    versionCode 314
    versionName "2.23.98"

    ndk {
        abiFilters 'armeabi-v7a','arm64-v8a','x86','x86_64'
    }
    // Add these lines below the existing config
    renderscriptTargetApi 23
    renderscriptSupportModeEnabled true
    vectorDrawables.useSupportLibrary = true

    testBuildType System.getProperty('testBuildType', 'debug')  // This will later be used to control the test apk build type
    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

    resConfigs "en"

    // https://react-native-iap.dooboolab.com/docs/installing
    missingDimensionStrategy 'store', 'play'
}
signingConfigs {
    release {
        if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
            storeFile file(MYAPP_RELEASE_STORE_FILE)
            storePassword MYAPP_RELEASE_STORE_PASSWORD
            keyAlias MYAPP_RELEASE_KEY_ALIAS
            keyPassword MYAPP_RELEASE_KEY_PASSWORD
        }
    }
}
splits {
    abi {
        reset()
        enable enableSeparateBuildPerCPUArchitecture
        universalApk false  // If true, also generate a universal APK
        include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
    }
}
buildTypes {
    release {
        minifyEnabled enableProguardInReleaseBuilds
        proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        signingConfig signingConfigs.release
    }
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
    variant.outputs.each { output ->
        // For each separate APK per architecture, set a unique version code as described here:
        // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
        def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
        def abi = output.getFilter(OutputFile.ABI)
        if (abi != null) {  // null for the universal-debug, universal-release variants
            output.versionCodeOverride =
                    versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
        }
        // apk name should be like: fanguru-app-1.0
        // update defaultConfig versionName name to this to work fine
        //output.outputFile = new File(output.outputFile.parent,
        //        "guru-fan-app-${variant.versionName}.apk")
    }
}
dexOptions {
    javaMaxHeapSize "4g"
    preDexLibraries = false
}
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

}

android { defaultConfig { multiDexEnabled true missingDimensionStrategy 'react-native-camera', 'general' testBuildType System.getProperty('testBuildType', 'debug') // This will later be used to control the test apk build type testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' } lintOptions { checkReleaseBuilds false // Or, if you prefer, you can continue to check for errors in release builds, // but continue the build even when errors are found: abortOnError false }

}

crashlytics { enableNdk false }

dependencies { if (enableHermes) { def hermesPath = "$nodeModules/hermes-engine/android/"; debugImplementation files(hermesPath + "hermes-debug.aar") releaseImplementation files(hermesPath + "hermes-release.aar") } else { implementation jscFlavor }

def multidex_version = "2.0.1"                                  //Line added to resolve error while creating apk/aab
implementation "androidx.multidex:multidex:$multidex_version"   //Line added to resolve error while creating apk/aab

implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "com.android.billingclient:billing:5.0.0"
implementation 'com.facebook.react:react-native'

// https://github.com/SudoPlz/react-native-amplitude-analytics#android-manual-installation
implementation 'com.amplitude:android-sdk:2.19.1' // native sdk of amplitude
implementation project(':react-native-amplitude-analytics')

// Firebase dependencies
// https://rnfirebase.io/docs/v5.x.x/installation/android#3.-Add-Firebase-modules
// implementation project(':react-native-firebase')
// implementation "com.google.android.gms:play-services-base:17.0.1"
// implementation "com.google.firebase:firebase-core:16.0.9"
implementation "com.google.firebase:firebase-messaging:18.0.0"
// implementation "com.google.firebase:firebase-perf:17.0.2"
// implementation 'com.google.firebase:firebase-inappmessaging-display:17.2.0'

// For animated GIF support
// https://frescolib.org/docs/index.html
implementation 'com.facebook.fresco:fresco:2.0.0'
implementation 'com.facebook.fresco:animated-gif:2.0.0'
implementation 'com.android.support:support-core-utils:24.2.1'

implementation 'com.android.support:exifinterface:27.+'

// implementation('com.facebook.android:facebook-android-sdk:[5,6)') {
//     exclude group: 'com.parse.bolts', module: 'bolts-android';
//     exclude group: 'com.parse.bolts', module: 'bolts-applinks';
//     exclude group: 'com.parse.bolts', module: 'bolts-tasks';
// }
implementation 'com.facebook.android:facebook-android-sdk:4.26.0'

// For Detox tests
androidTestImplementation('com.wix:detox:+') { transitive = true } 
androidTestImplementation 'junit:junit:4.12'

// From node_modules
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation('com.crashlytics.sdk.android:crashlytics:2.9.0@aar') {
    transitive = true;
}
implementation 'com.google.android.exoplayer:exoplayer:2.7.1'

// coroutines!
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.2'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.2'

// for PDF viewer
implementation 'com.otaliastudios:zoomlayout:1.7.0'

    implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
implementation 'com.google.android.gms:play-services-maps:17.0.0'
implementation 'com.facebook.soloader:soloader:0.11.0+'
implementation 'org.jetbrains:annotations:16.0.2'


debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
  exclude group:'com.facebook.fbjni'
}
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
    exclude group:'com.facebook.flipper'

    // https://stackoverflow.com/questions/60926425/java-lang-runtimeexception-requested-enabled-devsupportmanager-but-devsupportm
    exclude group:'com.squareup.okhttp3', module:'okhttp'
}
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
    exclude group:'com.facebook.flipper'
}

}

configurations.all { // fixes a Detox dependency resolutionStrategy { force 'androidx.annotation:annotation:1.0.2' } }

// Run this once to be able to run the application with BUCK // puts all compile dependencies into folder libs for BUCK to use task copyDownloadableDepsToLibs(type: Copy) { from configurations.compile into 'libs' }

project.ext.vectoricons = [ iconFontNames: [ 'MaterialIcons.ttf', 'MaterialCommunityIcons.ttf', 'Entypo.ttf' ] // Name of the font files you want to copy ]

apply from: file("$nodeModules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project) apply from: "$nodeModules/react-native-vector-icons/fonts.gradle"

apply plugin: 'kotlin-android'

// this should be last // https://rnfirebase.io/docs/v5.x.x/installation/android#2.-Setup-google-services.json apply plugin: 'com.google.gms.google-services'

// fixes dependency resolution error // invertase/react-native-firebase#1155 (comment) // GoogleServicesPlugin.config.disableVersionCheck = true

Please let me know if any solution.

error: cannot find symbol
return super.registerReceiver(receiver, filter, Context.RECEIVER_EXPORTED);
^
symbol: variable RECEIVER_EXPORTED
location: class Context

Getting above error while running

@kunal-kudale-invimatic
Copy link

error: cannot find symbol
return super.registerReceiver(receiver, filter, Context.RECEIVER_EXPORTED);
^
symbol: variable RECEIVER_EXPORTED
location: class Context

Guyz any solution for above issue? My react-native version 0.62.3. And below is my package.json, just in case if I need to update any library.

{
"name": "MY_PROJEXT_NAME",
"version": "2.23.98",
"private": true,
"workspaces": {
"nohoist": [
"detox"
]
},
"scripts": {
"start": "npx react-native start",
"start-test": "cross-env TEST_ENV=true react-native start",
"android:build": "react-native run-android",
"android": "npm-run-all --parallel --print-label start android:build",
"android-qa": "cross-env QA=true react-native run-android --variant=release --no-packager",
"android-release": "react-native run-android --variant=release --no-packager",
"ios:build": "react-native run-ios --device",
"ios": "npm-run-all --parallel --print-label start ios:build",
"ios-qa": "cross-env QA=true react-native run-ios --device --configuration=Release --no-packager",
"ios-release": "react-native run-ios --device --configuration=Release --no-packager",
"pod-install": "cd ios; pod install; cd ..",
"test": "jest --forceExit",
"android-e2e": "yarn start-test & detox build -c android && detox test -c android",
"ios-e2e": "yarn start-test & detox build -c ios && detox test -c ios",
"e2e": "yarn android-e2e & yarn ios-e2e",
"logcat": "adb logcat | grep ReactNativeJS",
"logcat-windows": "adb logcat | Select-String -Pattern "ReactNativeJS"",
"adb-reverse": "adb reverse tcp:8081 tcp:8081",
"prepare": "node ../../scripts/post.js",
"unity-export": "bash ../../scripts/unzip-unity-exports.sh",
"bundle-test": "react-native bundle --entry-file=./index.js --bundle-output=./bundle.js",
"version": "node scripts/version.js && git add -A",
"typecheck": "tsc --noEmit",
"ci": "npm-run-all --parallel --print-label --continue-on-error test typecheck bundle-test",
"find-unused": "bash ./scripts/find-unused.sh",
"create-native-assets": "node scripts/create-native-assets.js"
},
"dependencies": {
"@eventology/frontend-state": "^2.0.1",
"@invertase/react-native-apple-authentication": "^1.1.1",
"@mobile/config": "^2.23.86",
"@mobile/core": "^2.23.92",
"@notifee/react-native": "5.7.0",
"@react-native-community/async-storage": "^1.7.1",
"@react-native-community/cameraroll": "^1.3.0",
"@react-native-community/datetimepicker": "^3.0.4",
"@react-native-community/geolocation": "^2.0.2",
"@react-native-community/masked-view": "^0.1.9",
"@react-native-community/netinfo": "^5.3.2",
"@react-native-community/picker": "^1.8.1",
"@react-native-firebase/analytics": "14.12.0",
"@react-native-firebase/app": "14.12.0",
"@react-native-firebase/messaging": "14.12.0",
"@react-navigation/bottom-tabs": "^5.11.11",
"@react-navigation/drawer": "^5.12.5",
"@react-navigation/native": "^5.9.4",
"@react-navigation/stack": "^5.14.5",
"agora-rn-uikit": "^3.3.0",
"axios": "^0.21.1",
"bugsnag-react-native": "^2.23.4",
"card-validator": "^6.2.0",
"compare-versions": "^3.5.1",
"geolib": "^3.2.1",
"get-youtube-id": "^1.0.1",
"hash.js": "^1.1.7",
"idx": "^2.5.6",
"invariant": "^2.2.4",
"linkifyjs": "^2.1.8",
"lodash": "^4.17.15",
"mobx": "^5.15.1",
"mobx-react": "6.1.4",
"moment": "^2.24.0",
"phone": "^2.4.3",
"polished": "^4.0.3",
"react": "",
"react-native": "
",
"react-native-actionsheet": "^2.4.2",
"react-native-agora": "^3.5.0",
"react-native-amplitude-analytics": "^0.2.7",
"react-native-branch": "^4.3.0",
"react-native-camera": "^3.15.1",
"react-native-device-info": "^5.5.3",
"react-native-drag-sort": "^1.3.6",
"react-native-fbsdk-next": "^3.0.1",
"react-native-fs": "^2.16.2",
"react-native-gesture-handler": "^1.6.1",
"react-native-google-places-autocomplete": "^1.4.1",
"react-native-iap": "^7.5.0",
"react-native-image-crop-picker": "0.36.4",
"react-native-image-picker": "4.0.0",
"react-native-maps": "^0.26.1",
"react-native-mixpanel": "^1.1.14",
"react-native-modal": "^13.0.1",
"react-native-modal-datetime-picker": "^9.0.0",
"react-native-orientation": "^3.1.3",
"react-native-permissions": "3.6.0",
"react-native-picker-select": "8.0.3",
"react-native-qrcode-svg": "^6.0.3",
"react-native-rate": "1.2.12",
"react-native-reanimated": "^1.8.0",
"react-native-render-html": "^4.2.0",
"react-native-safe-area-context": "^0.7.3",
"react-native-screens": "^2.5.0",
"react-native-sms": "^1.10.0",
"react-native-snap-carousel": "^3.9.1",
"react-native-splash-screen": "3.2.0",
"react-native-square-in-app-payments": "1.3.1",
"react-native-status-bar-height": "^2.4.0",
"react-native-svg": "^12.0.3",
"react-native-svg-uri": "eventology/react-native-svg-uri#b5c28ddcc47ad48ebdb6092ca5334b80a9ad7b18",
"react-native-tab-view": "^2.14.0",
"react-native-thumbnail": "phuochau/react-native-thumbnail#dc9af06fcee553dce561158cfb05e915655634bb",
"react-native-vector-icons": "^6.6.0",
"react-native-version-number": "^0.3.6",
"react-native-video": "^5.1.0-alpha8",
"react-native-video-player": "^0.10.1",
"react-native-view-shot": "^3.0.2",
"react-native-webview": "^11.0.2",
"react-native-youtube": "^2.0.0",
"react-query": "^3.39.0",
"rn-fetch-blob": "joltup/rn-fetch-blob#0f6c3e3cc1c9c3c4b1640c8da42adffc3d620e90",
"sendbird": "^3.0.115",
"snapshot-diff": "^0.8.1",
"socket.io-client": "^3.1.0",
"styled-components": "^5.3.0",
"tipsi-stripe": "^7.5.3",
"url-parse": "^1.4.7",
"uuid": "^3.3.3"
},
"devDependencies": {
"@babel/core": "^7.9.0",
"@babel/plugin-proposal-decorators": "^7.8.3",
"@babel/preset-typescript": "^7.9.0",
"@types/babel__core": "^7.1.3",
"@types/card-validator": "^4.1.0",
"@types/detox": "^14.5.2",
"@types/invariant": "^2.2.31",
"@types/jest": "^24.0.25",
"@types/linkifyjs": "^2.1.3",
"@types/lodash": "^4.14.149",
"@types/phone": "^2.4.0",
"@types/prettier": "~1.19.0",
"@types/react": "",
"@types/react-devtools": "^3.6.0",
"@types/react-dom": "^17.0.1",
"@types/react-native": "
",
"@types/react-native-actionsheet": "^2.4.1",
"@types/react-native-maps": "^0.24.0",
"@types/react-native-mixpanel": "^0.1.0",
"@types/react-native-orientation": "^5.0.1",
"@types/react-native-snap-carousel": "^3.7.4",
"@types/react-native-status-bar-height": "^2.1.0",
"@types/react-native-svg-uri": "^1.2.3",
"@types/react-native-vector-icons": "^6.4.5",
"@types/react-native-version-number": "^0.3.0",
"@types/react-native-video": "^5.0.3",
"@types/react-native-video-player": "^0.10.1",
"@types/react-test-renderer": "^16.9.1",
"@types/rn-fetch-blob": "^1.2.1",
"@types/sharp": "^0.24.0",
"@types/styled-components": "^5.1.11",
"@types/url-parse": "^1.4.3",
"@types/uuid": "^3.4.6",
"axios-mock-adapter": "^1.17.0",
"babel-jest": "^25.2.4",
"babel-plugin-idx": "^2.4.0",
"babel-plugin-module-resolver": "^4.0.0",
"babel-plugin-transform-inline-environment-variables": "^0.4.3",
"babel-plugin-transform-remove-console": "^6.9.4",
"cross-env": "^7.0.0",
"detox": "^17.14.9",
"jest": "^25.1.0",
"jest-circus": "^26.6.3",
"jest-html-reporters": "^2.0.1",
"jetifier": "^1.6.5",
"metro-react-native-babel-preset": "^0.59.0",
"npm-run-all": "^4.1.5",
"react-devtools": "^4.4.0",
"react-dom": "^16.12.0",
"react-native-testing-library": "^1.12.0",
"react-test-renderer": "^17.0.1",
"sharp": "^0.32.5",
"ts-prune": "^0.8.4",
"typescript-styled-plugin": "^0.15.0",
"typesync": "^0.6.1",
"wait-for-expect": "^3.0.1"
},
"detox": {
"configurations": {
"ios": {
"binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/Fanguru.app",
"build": "xcodebuild -workspace ios/Fanguru.xcworkspace -scheme Fanguru -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build",
"type": "ios.simulator",
"name": "iPhone 11"
},
"android": {
"binaryPath": "android/app/build/outputs/apk/debug/app-debug.apk",
"build": "cd android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug && cd ..",
"type": "android.emulator",
"name": "5.1_WVGA_API_25"
}
},
"test-runner": "jest"
}
}

Please respond if any solution is found, I am trying at my end since last 1 week.

@kinloveko
Copy link

Thanks everyone! To put it together, adding the following code did the trick for me (react-native 0.69.12)
MainApplication.java

// Add imports
import android.content.BroadcastReceiver;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Build;
import org.jetbrains.annotations.Nullable;

// ...

// Put this above  "public void onCreate()":
  @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);
    }
  }
// ....

app/build.gradle

dependencies {
     //  ...
    implementation 'org.jetbrains:annotations:16.0.2'
    // ...
}

This also worked on my end!

2019 app and removed by google for depreciated dependencies and a lot to stuffs to upgrade

react-native 0.67.5
firebase 16.7.5
buildToolsVersion = "34.0.0" //was 33
minSdkVersion = 21
compileSdkVersion = 34 //was 33
targetSdkVersion = 34 //was 33

@kunal-kudale-invimatic
Copy link

kunal-kudale-invimatic commented Aug 12, 2024

Thanks everyone! To put it together, adding the following code did the trick for me (react-native 0.69.12)
MainApplication.java

// Add imports
import android.content.BroadcastReceiver;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Build;
import org.jetbrains.annotations.Nullable;

// ...

// Put this above  "public void onCreate()":
  @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);
    }
  }
// ....

app/build.gradle

dependencies {
     //  ...
    implementation 'org.jetbrains:annotations:16.0.2'
    // ...
}

Thanks @Sebosam @christophby so much, this solution working fine! I've been sleepless since last week because of these issues

@wendysychan is your application works after build an .apk file or .aab ??? or just locally on simulator ?

Sorry for late reply @dariusz-rosiek-branchspace , yes its working after build .apk and also .aab with very old RN version 0.62.3

I am having same react-native version still facing same issue. Can you please help @wendysychan ?

@wendysychan
Copy link

Thanks everyone! To put it together, adding the following code did the trick for me (react-native 0.69.12)
MainApplication.java

// Add imports
import android.content.BroadcastReceiver;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Build;
import org.jetbrains.annotations.Nullable;

// ...

// Put this above  "public void onCreate()":
  @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);
    }
  }
// ....

app/build.gradle

dependencies {
     //  ...
    implementation 'org.jetbrains:annotations:16.0.2'
    // ...
}

Thanks @Sebosam @christophby so much, this solution working fine! I've been sleepless since last week because of these issues

@wendysychan is your application works after build an .apk file or .aab ??? or just locally on simulator ?

Sorry for late reply @dariusz-rosiek-branchspace , yes its working after build .apk and also .aab with very old RN version 0.62.3

I am having same react-native version still facing same issue. Can you please help @wendysychan ?

Hi, could you send a screenshot of the error you're encountering?

@kunal-kudale-invimatic
Copy link

Thanks everyone! To put it together, adding the following code did the trick for me (react-native 0.69.12)
MainApplication.java

// Add imports
import android.content.BroadcastReceiver;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Build;
import org.jetbrains.annotations.Nullable;

// ...

// Put this above  "public void onCreate()":
  @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);
    }
  }
// ....

app/build.gradle

dependencies {
     //  ...
    implementation 'org.jetbrains:annotations:16.0.2'
    // ...
}

Thanks @Sebosam @christophby so much, this solution working fine! I've been sleepless since last week because of these issues

@wendysychan is your application works after build an .apk file or .aab ??? or just locally on simulator ?

Sorry for late reply @dariusz-rosiek-branchspace , yes its working after build .apk and also .aab with very old RN version 0.62.3

I am having same react-native version still facing same issue. Can you please help @wendysychan ?

Hi, could you send a screenshot of the error you're encountering?

Screenshot 2024-08-13 at 12 00 36 PM

@raelgc
Copy link

raelgc commented Aug 13, 2024

Like others, I'm using an old version of React Native, which requires SDK target as 33, but we've upgraded gradle.

Another simple workaround (because Google will reject your submission due SDK being old) is update android/build.gradle and change compileSdk to be 34, but keep target version as 33.

In my case, this is my build.gradle:

import groovy.json.JsonSlurper

buildscript {
    ext {
        buildToolsVersion = "34.0.0"
        minSdkVersion = 21
        compileSdkVersion = 34
        targetSdkVersion = 33
        supportLibVersion = "34.0.0"
        kotlinVersion = "1.9.0"
    }

 ...

@efec89
Copy link

efec89 commented Aug 13, 2024

import android.content.Context;

solving this problem

@madhurgang
Copy link

madhurgang commented Aug 14, 2024

Thanks everyone! To put it together, adding the following code did the trick for me (react-native 0.69.12)
MainApplication.java

// Add imports
import android.content.Context;
import android.content.BroadcastReceiver;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Build;
import org.jetbrains.annotations.Nullable;

// ...

// Put this above  "public void onCreate()":
  @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);
    }
  }
// ....

app/build.gradle

dependencies {
     //  ...
    implementation 'org.jetbrains:annotations:16.0.2'
    // ...
}

Thanks @Sebosam @christophby so much, this solution working fine! I've been sleepless since last week because of these issues

@wendysychan is your application works after build an .apk file or .aab ??? or just locally on simulator ?

Sorry for late reply @dariusz-rosiek-branchspace , yes its working after build .apk and also .aab with very old RN version 0.62.3

HI, @wendysychan
I tried and its not working for :

react-native: 0.63.1
JDK 11
gradle-6.9

Error: cannot find symbol
return super.registerReceiver(receiver, filter, Context.RECEIVER_EXPORTED);
^
symbol: variable RECEIVER_EXPORTED
location: class Context

Screenshot 2024-08-14 at 1 15 25 PM

@kinloveko
Copy link

This also worked on my end the app won't crash anymore but when i send it for review in google play console it says that

Issue found: Violation of Broken Functionality policy
Your app contains content that isn’t compliant with the Broken Functionality policy.

App loads, but crashes

react-native 0.67.5
firebase 16.7.5
buildToolsVersion = "34.0.0" //was 33
minSdkVersion = 21
compileSdkVersion = 34 //was 33
targetSdkVersion = 34 //was 33

**MainApplication.java**


> 
> // Add imports
> import android.content.BroadcastReceiver;
> import android.content.Intent;
> import android.content.IntentFilter;
> import android.os.Build;
> import org.jetbrains.annotations.Nullable;
> 
> // ...
> 
> // Put this above  "public void onCreate()":
>   @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);
>     }
>   }
> 
> **app/build.gradle**
> 
> dependencies {
>     
>     implementation 'org.jetbrains:annotations:16.0.2'
>   
> }

@kunal-kudale-invimatic
Copy link

Thanks everyone! To put it together, adding the following code did the trick for me (react-native 0.69.12)
MainApplication.java

// Add imports
import android.content.Context;
import android.content.BroadcastReceiver;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Build;
import org.jetbrains.annotations.Nullable;

// ...

// Put this above  "public void onCreate()":
  @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);
    }
  }
// ....

app/build.gradle

dependencies {
     //  ...
    implementation 'org.jetbrains:annotations:16.0.2'
    // ...
}

Thanks @Sebosam @christophby so much, this solution working fine! I've been sleepless since last week because of these issues

@wendysychan is your application works after build an .apk file or .aab ??? or just locally on simulator ?

Sorry for late reply @dariusz-rosiek-branchspace , yes its working after build .apk and also .aab with very old RN version 0.62.3

HI, @wendysychan I tried and its not working for :

react-native: 0.63.1 JDK 11 gradle-6.9

Error: cannot find symbol return super.registerReceiver(receiver, filter, Context.RECEIVER_EXPORTED); ^ symbol: variable RECEIVER_EXPORTED location: class Context

Screenshot 2024-08-14 at 1 15 25 PM

I am also facing same issue,

reat-native - 0.62.3
JDK - 11
grdale - 6.3

@chaitanya71998
Copy link

Thanks everyone! To put it together, adding the following code did the trick for me (react-native 0.69.12)

MainApplication.java

// Add imports
import android.content.BroadcastReceiver;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Build;
import org.jetbrains.annotations.Nullable;

// ...

// Put this above  "public void onCreate()":
  @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);
    }
  }
// ....

app/build.gradle

dependencies {
     //  ...
    implementation 'org.jetbrains:annotations:16.0.2'
    // ...
}

@christophby there was this import statement missing your comment can you check is this below necessary import and update your comment? It will be easier for resolving this issue.

import android.content.Context;

@miteshdb
Copy link

Big thanks to @christophby and everyone for keeping the community alive and helping each other. The solution to put the method below inside MainApplication.java worked.

import android.content.BroadcastReceiver;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Build;
import androidx.annotation.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);
    }
  }

Below should be added to the dependencies section of the app/build.gradle file.

implementation 'org.jetbrains:annotations:16.0.2'

@quoctruongkt
Copy link

I was able to upgrade my targetSDKVersion and compiledSDKVersion to 34 with the current fix provided by putting up the fix below.

But after generating a signed aab and uploading it to internal testing track in play console. This error shows up. Did anyone found a solution to resolve this error?

image

Thanks everyone! To put it together, adding the following code did the trick for me (react-native 0.69.12)
MainApplication.java

// Add imports
import android.content.BroadcastReceiver;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Build;
import org.jetbrains.annotations.Nullable;

// ...

// Put this above  "public void onCreate()":
  @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);
    }
  }
// ....

app/build.gradle

dependencies {
     //  ...
    implementation 'org.jetbrains:annotations:16.0.2'
    // ...
}

Thanks @Sebosam @christophby so much, this solution working fine! I've been sleepless since last week because of these issues

Thanks for sharing. This solution works very well

Thank you, this works for me
react-native 0.70.6

@phuongwd
Copy link

phuongwd commented Aug 23, 2024

Thanks everyone! To put it together, adding the following code did the trick for me (react-native 0.69.12)

MainApplication.java

// Add imports
import android.content.BroadcastReceiver;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Build;
import org.jetbrains.annotations.Nullable;

// ...

// Put this above  "public void onCreate()":
  @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);
    }
  }
// ....

app/build.gradle

dependencies {
     //  ...
    implementation 'org.jetbrains:annotations:16.0.2'
    // ...
}

Original solution by christophby; see #41288 (comment)

Thank you so much! This works for me with "react-native": "0.71.8".

@isha-18Pixels
Copy link

thanks it worked

@anggaip
Copy link

anggaip commented Aug 27, 2024

Thanks everyone! To put it together, adding the following code did the trick for me (react-native 0.69.12)

MainApplication.java

// Add imports
import android.content.BroadcastReceiver;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Build;
import org.jetbrains.annotations.Nullable;

// ...

// Put this above  "public void onCreate()":
  @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);
    }
  }
// ....

app/build.gradle

dependencies {
     //  ...
    implementation 'org.jetbrains:annotations:16.0.2'
    // ...
}

Thanks, you saved my times

@duarteacin
Copy link

duarteacin commented Aug 27, 2024

Thanks everyone! To put it together, adding the following code did the trick for me (react-native 0.69.12)
MainApplication.java

// Add imports
import android.content.BroadcastReceiver;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Build;
import org.jetbrains.annotations.Nullable;

// ...

// Put this above  "public void onCreate()":
  @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);
    }
  }
// ....

app/build.gradle

dependencies {
     //  ...
    implementation 'org.jetbrains:annotations:16.0.2'
    // ...
}

For me, it only works in debug mode with React Native version 0.64.2, but in release mode, it crashes right after opening the app. Does anyone have any ideas or suggestions? I would greatly appreciate your help

@ravindra3003 i was also trying to resolve this issue using the solution from @asaejiro but it didn't work for me. So what i did was to Clean > Build the project first so the index.android.bundle is generated and then manually copy the file into the /android/app/build/intermediates/assets/release/mergeReleaseAssets folder.
Then i generate the APK or App bundle and after which i analyze the APK and i see the index.android.bundle is packaged correctly and the app runs on my physical phone now.
Maybe you can give it a try too.

Yes, it's working for now. Please inform me if you discover a permanent solution.

You can add the following code to your node_modules\react-native\react.gradle file:
image

Install a lib https://www.npmjs.com/package/patch-package and generate a patch of react-native lib.

Hope it helps 😉

@prashant-ksolves-consultant
Copy link

prashant-ksolves-consultant commented Sep 4, 2024

Big thanks to @christophby and everyone for keeping the community alive and helping each other. The solution to put the method below inside MainApplication.java worked.

import android.content.BroadcastReceiver;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Build;
import androidx.annotation.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);
    }
  }

Below should be added to the dependencies section of the app/build.gradle file.

implementation 'org.jetbrains:annotations:16.0.2'

My RN version is 0.70.14
Though this resolved the crash issue, I still want to slowly upgrade RN version.
Which stable RN version I should target next, so that multiple things do not break simultaneously. I want to gradually upgrade the RN version.

@DanushkaPerusinghe
Copy link

DanushkaPerusinghe commented Sep 6, 2024

Thanks everyone! To put it together, adding the following code did the trick for me (react-native 0.69.12)

MainApplication.java

// Add imports
import android.content.BroadcastReceiver;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Build;
import org.jetbrains.annotations.Nullable;

// ...

// Put this above  "public void onCreate()":
  @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);
    }
  }
// ....

app/build.gradle

dependencies {
     //  ...
    implementation 'org.jetbrains:annotations:16.0.2'
    // ...
}

"react": "18.2.0",
"react-native": "0.71.7",

This woks thanks a lot :)

@Akifcan
Copy link

Akifcan commented Sep 10, 2024

Thanks everyone! To put it together, adding the following code did the trick for me (react-native 0.69.12)
MainApplication.java

// Add imports
import android.content.BroadcastReceiver;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Build;
import org.jetbrains.annotations.Nullable;

// ...

// Put this above  "public void onCreate()":
  @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);
    }
  }
// ....

app/build.gradle

dependencies {
     //  ...
    implementation 'org.jetbrains:annotations:16.0.2'
    // ...
}

"react": "18.2.0", "react-native": "0.71.7",

This woks thanks a lot :)

import android.content.Context;

I also added this line: import android.content.Context;

@kunal-kudale-invimatic
Copy link

Thanks everyone! To put it together, adding the following code did the trick for me (react-native 0.69.12)
MainApplication.java

// Add imports
import android.content.Context;
import android.content.BroadcastReceiver;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Build;
import org.jetbrains.annotations.Nullable;

// ...

// Put this above  "public void onCreate()":
  @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);
    }
  }
// ....

app/build.gradle

dependencies {
     //  ...
    implementation 'org.jetbrains:annotations:16.0.2'
    // ...
}

Thanks @Sebosam @christophby so much, this solution working fine! I've been sleepless since last week because of these issues

@wendysychan is your application works after build an .apk file or .aab ??? or just locally on simulator ?

Sorry for late reply @dariusz-rosiek-branchspace , yes its working after build .apk and also .aab with very old RN version 0.62.3

HI, @wendysychan I tried and its not working for :

react-native: 0.63.1 JDK 11 gradle-6.9

Error: cannot find symbol return super.registerReceiver(receiver, filter, Context.RECEIVER_EXPORTED); ^ symbol: variable RECEIVER_EXPORTED location: class Context

Screenshot 2024-08-14 at 1 15 25 PM

Any one still struggling with this issue, I found a workaround. After updating compileSDKVersion & targetSDKVersion to 34. I was getting error for Context.RECEIVER_EXPORTED. After spending more than month, I found in my android->build.gradle, there is block added for supporting some old versions of dependencies I guess, that code block is as below.

subprojects {
afterEvaluate {
project ->
if (project.hasProperty("android")) {
android {
compileSdkVersion = 34
buildToolsVersion = "28.0.3"
}
}
}
}

here compileSdkVersion was "28" which was causing issue, after updating it to 34(even 33 works) it worked.

And also if anyone using "react-native-orientaion", please follow below link.

https://medium.com/@anaz_19473/react-native-app-crashes-on-upgrading-to-targetsdkversion-34-android-14-f8f575da6b45

@Djotchuang
Copy link

Please note that it may be necessary to add the android.content.Context line to your imports. Also, if your files are in Kotlin, you'd have to convert the java code to kotlin. Check my comment on StackOverflow. https://stackoverflow.com/a/79003676/9883035

@odesey
Copy link

odesey commented Oct 7, 2024

To anyone still having problems with this, I followed all the steps above and my app was still crashing. I had to update ALL my packages to support Android 14 and then everything worked. Here are some of the packages I had to update:

@react-native-firebase/app, @react-native-firebase/messaging, react-native-maps, react-native-navigation, react-native-sound-player, @notifee/react-native, react-native-device-info

After updating those packages, the update to Android worked.

@Dance225
Copy link

Thanks guys, help a lot of!!!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests