react-native icon indicating copy to clipboard operation
react-native copied to clipboard

Instantly crash on Android

Open theobouwman opened this issue 2 years ago • 4 comments

Description

I get an instant crash on Android 12 Pixel 3A (physical):

Fatal Exception: java.lang.IllegalArgumentException: com.momoappamsterdam.momo: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
       at android.app.PendingIntent.checkFlags(PendingIntent.java:375)
       at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:645)
       at android.app.PendingIntent.getBroadcast(PendingIntent.java:632)
       at androidx.work.impl.utils.ForceStopRunnable.getPendingIntent(ForceStopRunnable.java:285)
       at androidx.work.impl.utils.ForceStopRunnable.isForceStopped(ForceStopRunnable.java:158)
       at androidx.work.impl.utils.ForceStopRunnable.forceStopRunnable(ForceStopRunnable.java:185)
       at androidx.work.impl.utils.ForceStopRunnable.run(ForceStopRunnable.java:103)
       at androidx.work.impl.utils.SerialExecutor$Task.run(SerialExecutor.java:91)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
       at java.lang.Thread.run(Thread.java:920)

And on emulator no crash at all.

Version

0.70.5

Output of npx react-native info

System:
    OS: macOS 12.6
    CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
    Memory: 184.92 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 18.10.0 - /usr/local/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 8.19.2 - /usr/local/bin/npm
    Watchman: Not Found
  Managers:
    CocoaPods: 1.11.2 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 21.4, iOS 16.0, macOS 12.3, tvOS 16.0, watchOS 9.0
    Android SDK:
      API Levels: 30, 31, 33
      Build Tools: 29.0.2, 30.0.2, 30.0.3, 31.0.0, 33.0.0
      System Images: android-30 | Google APIs Intel x86 Atom, android-30 | Google Play Intel x86 Atom
      Android NDK: Not Found
  IDEs:
    Android Studio: 2021.3 AI-213.7172.25.2113.9014738
    Xcode: 14.0.1/14A400 - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.13 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 18.1.0 => 18.1.0 
    react-native: 0.70.5 => 0.70.5 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found


Steps to reproduce

It is working on Android Emulator but not on physical device.

These are my dependencies:

 "dependencies": {
    "@gorhom/bottom-sheet": "^4",
    "@react-native-firebase/analytics": "^15.7.0",
    "@react-native-firebase/app": "^15.7.0",
    "@react-native-firebase/auth": "^15.7.0",
    "@react-native-firebase/crashlytics": "^15.7.0",
    "@react-navigation/bottom-tabs": "^6.4.0",
    "@react-navigation/native": "^6.0.4",
    "@react-navigation/native-stack": "^6.2.2",
    "@reduxjs/toolkit": "^1.6.1",
    "@types/react-geocode": "^0.2.1",
    "moment": "^2.29.4",
    "promise": "^8.0.3",
    "react": "18.1.0",
    "react-dom": "17.0.2",
    "react-geocode": "^0.2.3",
    "react-native": "0.70.5",
    "react-native-config": "^1.4.11",
    "react-native-device-info": "^10.3.0",
    "react-native-geolocation-service": "^5.3.1",
    "react-native-gesture-handler": "~2.2.1",
    "react-native-maps": "0.30.2",
    "react-native-pell-rich-editor": "^1.8.8",
    "react-native-reanimated": "^2.10.0",
    "react-native-render-html": "^6.3.4",
    "react-native-safe-area-context": "4.2.4",
    "react-native-screens": "~3.11.1",
    "react-native-vector-icons": "^9.2.0",
    "react-native-web": "0.17.7",
    "react-native-webview": "^11.23.1",
    "react-redux": "^7.2.5",
    "redux": "^4.1.1",
    "redux-logger": "^3.0.6"
  },
  "devDependencies": {
    "@babel/core": "^7.12.9",
    "@babel/runtime": "^7.12.5",
    "@react-native-community/eslint-config": "^2.0.0",
    "@tsconfig/react-native": "^2.0.2",
    "@types/jest": "^26.0.23",
    "@types/react-native": "^0.70.4",
    "@types/react-native-vector-icons": "^6.4.12",
    "@types/react-test-renderer": "^18.0.0",
    "@typescript-eslint/eslint-plugin": "^5.37.0",
    "@typescript-eslint/parser": "^5.37.0",
    "babel-jest": "^26.6.3",
    "eslint": "^7.32.0",
    "jest": "^26.6.3",
    "metro-react-native-babel-preset": "0.72.3",
    "react-test-renderer": "18.1.0",
    "typescript": "^4.8.3"
  },

Snack, code example, screenshot, or link to a repository

None

theobouwman avatar Nov 07 '22 15:11 theobouwman

Hi @theobouwman, this is not a react-native issue specifically, its a flag introduced in android SDK target 31 and above (so its more of a native android requirement. according to docs you need to

Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.

you can read more about it here https://developer.android.com/about/versions/12/behavior-changes-12#pending-intent-mutability

and here https://medium.com/androiddevelopers/all-about-pendingintents-748c8eb8619

you might need to upgrade your Work Manager to 2.7.0-alpha02

ohheyitskartik avatar Nov 07 '22 16:11 ohheyitskartik

When I add it I still face the same issue:


dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])

    //noinspection GradleDynamicVersion
    implementation "com.facebook.react:react-native:+"  // From node_modules
    
    implementation "androidx.work:work-runtime:2.7.0-alpha02"
    implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"

    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'
        exclude group:'com.squareup.okhttp3', module:'okhttp'
    }

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

    if (enableHermes) {
        //noinspection GradleDynamicVersion
        implementation("com.facebook.react:hermes-engine:+") { // From node_modules
            exclude group:'com.facebook.fbjni'
        }
    } else {
        implementation jscFlavor
    }
}

And after the original error I also see this one:

E/SoLoader: couldn't find DSO to load: libjscexecutor.so

theobouwman avatar Nov 07 '22 17:11 theobouwman

When I add it I still face the same issue:

Also what are the steps to reproduce?

cortinico avatar Nov 07 '22 18:11 cortinico

:warning: Missing Reproducible Example
:information_source: It looks like your issue is missing a reproducible example. Please provide a Snack or a repository that demonstrates the issue you are reporting in a minimal, complete, and reproducible manner.

github-actions[bot] avatar Nov 07 '22 18:11 github-actions[bot]

I fixed it by creating a new project and reconfiguring all my packages. Once I the app was working I just copied the packages.json and android folder to my project. Lesson learned: always test on Android and iOS when adding packages etc.

theobouwman avatar Nov 13 '22 15:11 theobouwman