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

targetSdkVersion 33 to 34 app crash #45555

Closed
nan8420 opened this issue Jul 20, 2024 · 9 comments
Closed

targetSdkVersion 33 to 34 app crash #45555

nan8420 opened this issue Jul 20, 2024 · 9 comments
Labels
Resolution: Answered When the issue is resolved with a simple answer Type: Unsupported Version Issues reported to a version of React Native that is no longer supported

Comments

@nan8420
Copy link

nan8420 commented Jul 20, 2024

Description

I am using React Native version 0.71.6. When I changed targetSdkVersion from 33 to 34, the app crashed and there was no log. only in Android

and i also tried change MainApplication.java file

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

also

android/app/build.gradle

implementation 'org.jetbrains:annotations:16.0.2'

// add above the oncreate() 

I applied this and it works well in debug mode, both on the emulator and on the actual device. However, if you upload it to the Google Play Store as an internal test and run it, the app crashes again.

How can I solve this? Below are my files

android/build.gradle

buildscript {
    ext {
        buildToolsVersion = "33.0.0"
        minSdkVersion = 21
        compileSdkVersion = 33
        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"
        // react-native-iap
        supportLibVersion = "28.0.0"
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        
        classpath("com.android.tools.build:gradle:7.3.1")
        classpath("com.facebook.react:react-native-gradle-plugin")
        classpath 'com.google.gms:google-services:4.3.3'
    }
}

package.json

 "dependencies": {
    "@invertase/react-native-apple-authentication": "^2.2.2",
    "@react-native-community/art": "^1.2.0",
    "@react-native-community/async-storage": "^1.12.1",
    "@react-native-community/clipboard": "^1.5.1",
    "@react-native-community/masked-view": "^0.1.10",
    "@react-native-community/netinfo": "9.3.7",
    "@react-native-firebase/analytics": "^17.5.0",
    "@react-native-firebase/app": "^17.5.0",
    "@react-native-firebase/messaging": "^17.5.0",
    "@react-navigation/material-top-tabs": "^6.3.0",
    "@react-navigation/native": "^6.1.6",
    "@react-navigation/native-stack": "^6.9.2",
    "@react-navigation/stack": "^6.3.5",
    "@reduxjs/toolkit": "^1.9.2",
    "@shopify/react-native-skia": "^0.1.183",
    "@tanstack/react-query": "^4.13.5",
    "aws-sdk": "^2.777.0",
    "axios": "^1.6.7",
    "crypto-js": "3.2.0",
    "dayjs": "^1.11.10",
    "eventemitter3": "^4.0.7",
    "expo": "^48.0.0",
    "expo-asset": "~8.9.1",
    "expo-av": "~13.2.1",
    "expo-constants": "~14.2.1",
    "expo-file-system": "~15.2.2",
    "expo-font": "~11.1.1",
    "expo-haptics": "~12.2.1",
    "expo-jwt": "^1.4.1",
    "expo-linear-gradient": "~12.1.2",
    "expo-web-browser": "~12.1.1",
    "install-expo-modules": "^0.3.6",
    "lodash": "^4.17.20",
    "lottie-ios": "3.4.1",
    "lottie-react-native": "5.1.4",
    "lzutf8": "0.6.2",
    "patch-package": "^6.4.7",
    "pod-install": "^0.1.16",
    "postinstall-postinstall": "^2.1.0",
    "qs": "^6.9.4",
    "react": "18.2.0",
    "react-native": "0.71.6",
    "react-native-animated-webp": "^0.0.8",
    "react-native-code-push": "^8.0.1",
    "react-native-drawer-layout": "^3.2.0",
    "react-native-easy-toast": "^1.2.0",
    "react-native-fast-image": "^8.6.3",
    "react-native-flipper": "^0.189.0",
    "react-native-gesture-handler": "~2.9.0",
    "react-native-google-mobile-ads": "^10.1.2",
    "react-native-hyperlink": "^0.0.19",
    "react-native-iap": "^12.12.2",
    "react-native-immersive-mode": "^2.0.0",
    "react-native-pager-view": "6.1.2",
    "react-native-pages": "^0.9.0",
    "react-native-progress": "^4.1.2",
    "react-native-rate": "^1.2.4",
    "react-native-reanimated": "~2.14.4",
    "react-native-safe-area-context": "4.5.0",
    "react-native-screens": "~3.20.0",
    "react-native-tab-view": "^3.3.0",
    "react-native-webview": "11.26.0",
    "react-navigation": "^4.4.4",
    "react-navigation-stack": "^2.10.4",
    "react-redux": "^8.0.5",
    "reanimated-bottom-sheet": "^1.0.0-alpha.22",
    "redux-flipper": "^2.0.2",
    "request": "^2.88.2",
    "request-promise": "^4.2.6"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0",
    "@babel/eslint-parser": "^7.21.3",
    "@babel/plugin-proposal-class-properties": "^7.18.6",
    "@babel/preset-env": "^7.20.0",
    "@babel/runtime": "^7.20.0",
    "@react-native-community/eslint-config": "^3.2.0",
    "babel-jest": "^29.2.1",
    "babel-plugin-module-resolver": "^5.0.0",
    "babel-plugin-transform-remove-console": "^6.9.4",
    "eslint": "^8.19.0",
    "eslint-config-airbnb": "^19.0.4",
    "eslint-config-prettier": "^8.8.0",
    "eslint-import-resolver-babel-module": "^5.3.2",
    "eslint-plugin-import": "^2.27.5",
    "eslint-plugin-jsx-a11y": "^6.7.1",
    "eslint-plugin-prettier": "^4.2.1",
    "eslint-plugin-react": "^7.32.2",
    "eslint-plugin-react-hooks": "^4.3.0",
    "eslint-plugin-react-native": "^4.0.0",
    "jest": "^29.2.1",
    "metro-react-native-babel-preset": "0.73.9",
    "prettier": "^2.4.1",
    "react-query-native-devtools": "^4.0.0",
    "react-test-renderer": "18.2.0"
  },
  "jest": {
    "preset": "react-native"
  }
}

Steps to reproduce

yarn android

React Native Version

0.71.6

Affected Platforms

Runtime - Android

Output of npx react-native info

System:
    OS: macOS 13.5.1
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 368.43 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.15.1 - ~/.nvm/versions/node/v20.15.1/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.7.0 - ~/.nvm/versions/node/v20.15.1/bin/npm
    Watchman: 2024.03.25.00 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.14.3 - /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: Not Found
    Xcode: 15.0/15A240d - /usr/bin/xcodebuild
  Languages:
    Java: 17.0.12 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 18.2.0 => 18.2.0 
    react-native: 0.71.6 => 0.71.18 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Stacktrace or Logs

java.lang.RuntimeException

Exception java.lang.RuntimeException: Attempting to call runOnJS with an object that is not a host function. Using runOnJS is only possible with methods that are defined on the main React-Native Javascript thread and that aren't marked as worklets

Error: Attempting to call runOnJS with an object that is not a host function. Using runOnJS is only possible with methods that are defined on the main React-Native Javascript thread and that aren't marked as worklets
    at runOnJS (/Users/kimgunhee/Desktop/myproject/node_modules/react-native-reanimated/src/reanimated2/core.ts (302:7):1:86)
    at runOnJS (native)
    at _f (/Users/kimgunhee/Desktop/myproject/node_modules/react-native-drawer-layout/src/views/modern/Drawer.tsx (233:14):1:71)
    at _f (native)
    at _f (/Users/kimgunhee/Desktop/myproject/node_modules/react-native-reanimated/src/reanimated2/hook/useAnimatedGestureHandler.ts (54:18):1:624)
    at _f (native)
  at com.swmansion.reanimated.Scheduler.triggerUI (Scheduler.java)
  at com.swmansion.reanimated.Scheduler$1.run (Scheduler.java)
  at com.swmansion.reanimated.Scheduler$2.runGuarded (Scheduler.java)
  at com.facebook.react.bridge.GuardedRunnable.run
  at android.os.Handler.handleCallback (Handler.java:942)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at android.os.Looper.loopOnce (Looper.java:226)
  at android.os.Looper.loop (Looper.java:313)
  at android.app.ActivityThread.main (ActivityThread.java:8762)
  at java.lang.reflect.Method.invoke
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:604)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1067)


l6.c

Exception l6.c:
  at com.facebook.react.modules.core.ExceptionsManagerModule.reportException
  at java.lang.reflect.Method.invoke
  at com.facebook.react.bridge.JavaMethodWrapper.invoke
  at com.facebook.react.bridge.JavaModuleWrapper.invoke
  at com.facebook.jni.NativeRunnable.run
  at android.os.Handler.handleCallback (Handler.java:958)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage
  at android.os.Looper.loopOnce (Looper.java:230)
  at android.os.Looper.loop (Looper.java:319)
  at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run
  at java.lang.Thread.run (Thread.java:1012)

Reproducer

no

Screenshots and Videos

No response

@react-native-bot
Copy link
Collaborator

⚠️ Unsupported Version of React Native
ℹ️ It looks like your issue or the example you provided uses an unsupported version of React Native.

Due to the number of issues we receive, we're currently only accepting new issues against one of the supported versions. Please upgrade to latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If you cannot upgrade, please open your issue on StackOverflow to get further community support.

@react-native-bot react-native-bot added Type: Unsupported Version Issues reported to a version of React Native that is no longer supported Needs: Author Feedback Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. and removed Needs: Triage 🔍 labels Jul 20, 2024
@react-native-bot
Copy link
Collaborator

⚠️ Missing Reproducible Example
ℹ️ We could not detect a reproducible example in your issue report. Please provide either:
  • If your bug is UI related: a Snack
  • If your bug is build/update related: use our Reproducer Template. A reproducer needs to be in a GitHub repository under your username.

@react-native-bot
Copy link
Collaborator

⚠️ Unsupported Version of React Native
ℹ️ It looks like your issue or the example you provided uses an unsupported version of React Native.

Due to the number of issues we receive, we're currently only accepting new issues against one of the supported versions. Please upgrade to latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If you cannot upgrade, please open your issue on StackOverflow to get further community support.

@react-native-bot
Copy link
Collaborator

⚠️ Missing Reproducible Example
ℹ️ We could not detect a reproducible example in your issue report. Please provide either:

@migueldaipre
Copy link
Contributor

You need to upgrade the react native version to support the SDK version 34

@cortinico
Copy link
Contributor

I am using React Native version 0.71.6. When I changed targetSdkVersion from 33 to 34, the app crashed and there was no log. only in Android

As @migueldaipre correctly pointed out, you need to migrate to React Native 0.74 in order to do so.

@cortinico cortinico added Resolution: Answered When the issue is resolved with a simple answer and removed Needs: Author Feedback Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. labels Jul 21, 2024
@Siddhantshelake
Copy link

Siddhantshelake commented Jul 28, 2024

Detailed explanation and potential issue fixes are added and discussed in this Medium article:
https://medium.com/@siddhantshelake/fixing-broadcastreceiver-crashes-and-metro-server-issues-in-android-14-3b7d05939a43

@mkhotib20
Copy link

i'm faced this issue too, and upgrading to rn 0.74 fix my problem, but we need to bump min sdk version to 21,
i have more than 10% user that using device with android 5. can you guys give me another approach ???

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Answered When the issue is resolved with a simple answer Type: Unsupported Version Issues reported to a version of React Native that is no longer supported
Projects
None yet
Development

No branches or pull requests

7 participants