React Native - Android app restarts on background - android

My react-native android app restarts on background even in AdMob ads.
I newly added Google-AdMob ads to my app but when I take it to the background or watch Interstitial ads in the app, it restarts and starts over from the splash screen.
"dependencies":
"firebase": "^5.0.4",
"native-base": "^2.4.3",
"react": "16.3.1",
"react-native": "0.55.3",
"react-native-admob": "^2.0.0-beta.5",
"react-native-elements": "^0.19.1",
"react-native-fetch-blob": "^0.10.8",
"react-native-share": "^1.0.27",
"react-native-storage": "^0.2.2",
"react-native-vector-icons": "^4.6.0",
"react-native-video": "^2.0.0",
"react-native-view-shot": "^2.4.0",
"react-navigation": "^1.5.11",
"tty": "^1.0.1"
"devDependencies":
"babel-jest": "22.4.3",
"babel-preset-react-native": "4.0.0",
"jest": "22.4.3",
"react-test-renderer": "16.3.1"

Related

React native app crash on apk launch after using realm

I have a react native app using realm for saving user json input to device storage, then send the json data to api when they have stable connection (not automatically).
It works perfectly when used in debugging mode, but when I build it to apk and install to android device (the same one used for debugging), it crashes instantly without even showing the splash screen.
dependencies :
"#react-native-async-storage/async-storage": "^1.17.7",
"#react-native-community/cameraroll": "^4.0.0",
"#react-native-community/geolocation": "^2.0.2",
"#react-native-community/masked-view": "^0.1.10",
"#react-navigation/native": "^5.7.3",
"#react-navigation/stack": "^5.9.0",
"axios": "^0.20.0",
"buffer": "^6.0.1",
"formik": "^2.1.5",
"immer": "^9.0.3",
"react": "16.13.1",
"react-native": "0.63.2",
"react-native-android-location-services-dialog-box": "^2.8.2",
"react-native-bootsplash": "^3.1.5",
"react-native-camera": "^3.40.0",
"react-native-dropdown-picker": "^3.7.0",
"react-native-fs": "^2.16.6",
"react-native-gesture-handler": "^1.7.0",
"react-native-html-to-pdf": "^0.8.0",
"react-native-image-crop-picker": "^0.35.1",
"react-native-linear-gradient": "^2.5.6",
"react-native-maps": "^0.27.1",
"react-native-material-buttons": "^0.6.0",
"react-native-material-ripple": "^0.9.1",
"react-native-material-textfield": "^0.16.1",
"react-native-paper": "^4.1.0",
"react-native-permissions": "^2.2.1",
"react-native-reanimated": "1.13.0",
"react-native-safe-area-context": "^3.1.7",
"react-native-screens": "^2.10.1",
"react-native-svg": "^12.1.0",
"react-native-vector-icons": "^7.1.0",
"react-redux": "^7.2.1",
"realm": "10.19.5",
"redux": "^4.0.5",
"redux-devtools-extension": "^2.13.8",
"redux-logger": "^3.0.6",
"redux-offline": "^2.0.0",
"redux-persist": "^6.0.0",
"redux-saga": "^1.1.3"
I'm stuck with this for two days now.
Found some similar issues and have try this approaches :
Use v10.20.0-beta.5 -> can't even launch in debugging
Removing react-native-reanimated
Disable hermes (never enabled in the first place)
add this to defaultConfig inside android/app/build.gradle :
ndk {
abiFilters 'arm64-v8a', 'x86_64'
}
But nothing fixes the crash.
*I can't use AsyncStorage because of the 1MB cursor limit, and I will need to save maximum of 60MB. And I'm holding react native upgrade to 0.69 for now, because of the project's time limit.
How can I run the apk without crashing?
Thanks a bunch for your help!

My app closes instead of reloading after installing in app update

I am using react-native, and I want to add in app update to my app. At first I tried using sp-react-native-in-app-updates. But my app was closing after the update was done. "the expected behavior is to reload with the new version".
So I decided to go native and use native modules to implement in-app-update.for the native approach I have followed react-native-in-app-update. But, going native did not help me and My app closes when It's done installing the update. after the app closes if I open it again. it's the updated version. but, the expected behavior for the app is to immediately reloads after installing update.
To make sure I am doing everything in the right way. I have created an app from scratch and followed the same steps and I could get the desired result. The new app was reloading after installing the update.
Dependencies
"dependencies": {
"#ercpereda/react-native-accordion": "^2.0.6",
"#invertase/react-native-apple-authentication": "^1.1.2",
"#react-native-community/art": "^1.2.0",
"#react-native-community/cameraroll": "^4.1.2",
"#react-native-community/image-editor": "^2.3.0",
"#react-native-community/netinfo": "^4.6.1",
"#react-native-community/push-notification-ios": "^1.4.0",
"#react-native-firebase/analytics": "^6.0.4",
"#react-native-firebase/app": "^6.7.1",
"#sentry/react-native": "^1.1.0",
"axios": "^0.18.0",
"babel-plugin-transform-class-properties": "^6.24.1",
"css-loader": "^0.28.11",
"eslint-config-rallycoding": "^3.2.0",
"firebase": "^4.11.0",
"fuse.js": "^3.2.1",
"grpc": "^1.24.2",
"lodash": "^4.17.15",
"moment": "^2.21.0",
"patch-package": "^6.4.7",
"react": "17.0.2",
"react-loading-skeleton": "^0.4.0",
"react-native": "0.67.2",
"react-native-album-list": "^0.1.2",
"react-native-animatable": "^1.2.4",
"react-native-branch": "^4.2.1",
"react-native-calendars": "^1.20.0",
"react-native-camera": "^3.9.0",
"react-native-camera-roll-picker": "^1.3.0",
"react-native-carousel-view": "^0.5.1",
"react-native-checkbox": "^2.0.0",
"react-native-chip-view": "0.0.9",
"react-native-country-picker-modal": "^0.8.0",
"react-native-device-info": "^8.4.9",
"react-native-easy-grid": "^0.1.17",
"react-native-easy-toast": "^1.1.0",
"react-native-fabric": "^0.5.1",
"react-native-fast-image": "^8.3.2",
"react-native-fbsdk": "^3.0.0",
"react-native-flexi-radio-button": "^0.2.2",
"react-native-freshchat-sdk": "^3.3.2",
"react-native-geocoder": "^0.5.0",
"react-native-geolocation-service": "^3.1.0",
"react-native-gesture-handler": "^1.10.3",
"react-native-google-places": "^3.1.2",
"react-native-i18n": "^2.0.12",
"react-native-image-carousel": "^0.4.4",
"react-native-image-pan-zoom": "^2.1.7",
"react-native-image-resizer": "^1.0.0",
"react-native-image-size": "1.1.2",
"react-native-image-view": "^2.0.5",
"react-native-image-zoom-viewer": "^2.2.13",
"react-native-linear-gradient": "^2.5.6",
"react-native-maps": "^0.26.1",
"react-native-material-textfield": "^0.16.1",
"react-native-mixpanel": "^1.1.4",
"react-native-modal-datetime-picker": "^4.13.0",
"react-native-modest-checkbox": "^3.0.1",
"react-native-multiple-select-list": "^1.0.4",
"react-native-onesignal": "^3.5.0",
"react-native-otp": "^1.0.0",
"react-native-permissions": "^3.0.1",
"react-native-phone-call": "^1.0.7",
"react-native-popup-dialog": "^0.14.52",
"react-native-progress": "^4.0.2",
"react-native-push-notification": "^3.1.9",
"react-native-rate": "^1.1.10",
"react-native-reanimated": "^1.13.4",
"react-native-remote-svg": "^1.2.0",
"react-native-responsive-dimensions": "^1.0.2",
"react-native-restart": "0.0.13",
"react-native-router-flux": "^4.2.0",
"react-native-safe-area-context": "^3.1.9",
"react-native-safe-area-view": "^1.1.1",
"react-native-screens": "^2.18.1",
"react-native-select-multiple": "^1.2.0",
"react-native-shadow": "^1.2.2",
"react-native-shimmer-placeholder": "^1.0.35",
"react-native-simple-dialogs": "1.1.0",
"react-native-simple-radio-button": "^2.7.2",
"react-native-smooth-pincode-input": "^1.0.3",
"react-native-snackbar": "^2.0.4",
"react-native-snap-carousel": "3.8.0",
"react-native-splash-screen": "^3.2.0",
"react-native-svg": "^6.3.1",
"react-native-svg-animated-linear-gradient": "^0.1.9",
"react-native-svg-image": "^2.0.1",
"react-native-view-overflow": "0.0.4",
"react-native-webview": "^7.6.0",
"react-redux": "^5.0.7",
"redux": "^3.7.2",
"redux-logger": "^3.0.6",
"redux-thunk": "^2.2.0",
"rn-sliding-up-panel": "^2.4.5",
"sp-react-native-in-app-updates": "^1.1.6"
},
"devDependencies": {
"#babel/core": "^7.12.9",
"#babel/runtime": "^7.12.5",
"#react-native-community/eslint-config": "^2.0.0",
"babel-jest": "^26.6.3",
"eslint": "7.14.0",
"jest": "^26.6.3",
"metro-react-native-babel-preset": "^0.66.2",
"react-native-bundle-visualizer": "^2.0.1",
"react-test-renderer": "17.0.2"
},
Testing and Logcat_output:
To download apps using internal app sharing, You need to turn on internal app sharing on your Google Play Store app.
Open the Google Play Store app Google Play.
Tap Menu Menu > Settings.
In the “About” section, tap the Play Store version 7 times.
After the Internal app sharing setting appears, tap the switch to turn on internal app sharing.
Tap Turn on.
then open
https://play.google.com/apps/test/RQBrzWd6q_k/ahAIGJVrejKye6LymizzTdIY85wCTjmWtdA_ZIZ7OtU36IJS7H2TfZAiTckX-cEhcSuEjFdaLyGAKH8Dgfu4T2gvYr
and install the app
now if you open the app. It will not detect an update. For your app to detect the update. you have to open
https://play.google.com/apps/test/RQBrzWd6q_k/ahAIGJVrehWQvkt_2QCjcFlIDTvbtyy43A3XsD1hTAsn3fFCXy3tQgWjc8-oxYTUzJvAJsWXEWyX282iWl3c-heGpA
now go to your app and hopfully your app will detect the update

React native crash on android (RuntimeException)

I have had reports of crashes happening from our React Native app on android on launch but its not a crash that I have been able to recreate locally or with any devices I have to hand. The crash is happening before Sentry has been initialised in our app so have been very limited in the information to be able to diagnose it except from a log from one users device
2021-12-20 17:27:38,487 - [INFO::com.miui.bugreport] - BaseConstants: com.miui.cloudservice existence = true
2021-12-20 17:27:38,489 - [INFO::com.miui.bugreport] - BaseConstants: com.miui.bugreport existence = true
2021-12-20 17:27:39,038 - [INFO::com.miui.bugreport] - Utils: Current process is main process.
2021-12-20 17:27:39,067 - [INFO::com.miui.bugreport] - BugreportPushMessageReceiver: Push register success.
2021-12-20 17:27:39,068 - [INFO::com.miui.bugreport] - Utils: Current process is main process.
2021-12-20 17:27:40,199 - [INFO::com.miui.bugreport] - BugreportGenerateService: set sender package name. com.android.settings
2021-12-20 17:27:45,237 - [ERROR::com.miui.bugreport] - ReflectClass: Failed to call static method:set
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at b.d.e.a.a.c.b.a(SourceFile:10)
at b.d.e.a.a.c.a.a(SourceFile:11)
at b.d.e.a.a.c.a.a.b.b(SourceFile:2)
at com.miui.bugreport.service.i.a(SourceFile:39)
at com.miui.bugreport.service.BugreportGenerateService.a(SourceFile:67)
at com.miui.bugreport.service.BugreportGenerateService.onHandleIntent(SourceFile:12)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:77)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:236)
at android.os.HandlerThread.run(HandlerThread.java:67)
Caused by: java.lang.RuntimeException: failed to set system property (check logcat for reason)
at android.os.SystemProperties.native_set(Native Method)
at android.os.SystemProperties.set(SystemProperties.java:240)
... 11 more
2021-12-20 17:27:45,238 - [INFO::com.miui.bugreport] - BugreportGenerateService: Starts to dump Bugreport
2021-12-20 17:27:45,242 - [INFO::com.miui.bugreport] - DumpLogUtil: Starts to dump bugreport log to path=/storage/emulated/0/MIUI/debug_log//tmp/bugreport_1640017665238.log.tmp
2021-12-20 17:30:36,607 - [INFO::com.miui.bugreport] - DumpLogUtil: Bugreport file name = bugreport-galahad_eea-RP1A.200720.011-2021-12-20-17-27-45.zip
2021-12-20 17:30:41,631 - [INFO::com.miui.bugreport] - DumpLogUtil: Reads end of dumpstatez
2021-12-20 17:30:41,633 - [INFO::com.miui.bugreport] - DumpLogUtil: Dump bugreport complete and path=/storage/emulated/0/MIUI/debug_log//tmp/bugreport-galahad_eea-RP1A.200720.011-2021-12-20-17-27-45.zip
The crash happens for some users every time but not does not happen for all users and only affects android. Crash first started happening for users after updating to RN v0.66.3. Any thoughts on what the issue could be or how I could get any more useful information to diagnose this would be much appreciated!
Other potentially useful info:
package.json:
"dependencies": {
"#react-native-community/async-storage": "^1.12.0",
"#react-native-community/cli-platform-ios": "^4.13.0",
"#react-navigation/native": "^5.8.10",
"#sentry/react-native": "^1.8.2",
"color": "2.0.0",
"crypto-js": "3.1.9-1",
"graceful-fs": "^4.2.8",
"install": "0.10.1",
"lodash": "^4.17.20",
"moment": "^2.29.0",
"npm": "^5.10.0",
"prop-types": "^15.7.2",
"qs": "^6.10.1",
"react": "17.0.2",
"react-async": "^7.0.6",
"react-native": "0.66.3",
"react-native-cache": "^2.0.1",
"react-native-charts-wrapper": "^0.5.7",
"react-native-config": "^0.12.0",
"react-native-daterange-picker": "^1.5.1",
"react-native-gesture-handler": "^1.8.0",
"react-native-get-random-values": "^1.5.0",
"react-native-haptic-feedback": "^1.11.0",
"react-native-inappbrowser-reborn": "^3.6.3",
"react-native-keychain": "^4.0.5",
"react-native-mixpanel": "^1.2.5",
"react-native-modal": "^10.0.0",
"react-native-onesignal": "^3.6.4",
"react-native-reanimated": "^1.13.0",
"react-native-router-flux": "^4.2.0",
"react-native-screens": "^2.11.0",
"react-native-search-box": "0.0.19",
"react-native-share": "^2.0.0",
"react-native-star-rating": "^1.1.0",
"react-native-svg": "^9.13.6",
"react-native-svg-charts": "^5.4.0",
"react-native-swipeable": "^0.6.0",
"react-native-table-component": "^1.2.1",
"react-native-vector-icons": "^4.4.0",
"react-redux": "5.0.6",
"redux": "3.7.2",
"redux-thunk": "2.2.0",
"smartlook-react-native-wrapper": "^0.24.0",
"uuid": "^8.3.2"
},
"devDependencies": {
"#types/react": "^16.9.49",
"#types/react-native": "^0.61.23",
"#typescript-eslint/eslint-plugin": "^1.13.0",
"#typescript-eslint/parser": "^1.13.0",
"#babel/core": "^7.12.9",
"#babel/runtime": "^7.12.5",
"#react-native-community/eslint-config": "^2.0.0",
"babel-jest": "^26.6.3",
"eslint": "7.14.0",
"jest": "^26.6.3",
"metro-react-native-babel-preset": "^0.66.2",
"react-test-renderer": "17.0.2",
"babel-cli": "6.26.0",
"babel-core": "6.26.0",
"babel-eslint": "^10.1.0",
"babel-preset-airbnb": "2.4.0",
"chai": "4.1.2",
"chai-enzyme": "0.8.0",
"enzyme": "3.1.0",
"eslint-config-react-app": "^5.2.1",
"eslint-plugin-flowtype": "^3.13.0",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-jsx-a11y": "^6.3.1",
"eslint-plugin-react": "^7.21.1",
"eslint-plugin-react-hooks": "^1.7.0",
"fetch-mock": "5.12.2",
"husky": "^3.1.0",
"jsdom": "11.3.0",
"lint-staged": "^9.5.0",
"mocha": "4.0.0",
"prettier": "^1.19.1",
"react-dom": "^16.13.1",
"react-native-debugger-open": "^0.3.25",
"react-native-mock": "0.3.1",
"react-native-mock-render": "^0.1.9",
"redux-mock-store": "1.3.0",
"regenerator-runtime": "^0.13.7",
"sinon": "4.0.1",
"sinon-chai": "2.14.0",
"timekeeper": "2.0.0",
"underscore": "1.8.3"
},
build.gradle:
buildToolsVersion = "30.0.2"
minSdkVersion = 21
compileSdkVersion = 30
targetSdkVersion = 30
supportLibVersion = "30.0.0"
googlePlayServicesVersion = "16.0.0"
googlePlayServicesVisionVersion = "17.0.2"
ndkVersion = "21.4.7075529"
Have got to the bottom of it, if anyone else is experiencing the same issue.
The problem was with the initialisation of Sentry due to using an old version with a later version of React Native (but was only happening on a small number of Android devices). Issue was solved by upgrading from v1.8.2 to v3.2.10.

How to fix "EISDIR: illegal operation on a directory, read error" on react native android emulator with react native debug mode enabled

I am new to React and React Native and I am stuck with debugging process. I have used redux and want to check the action and state changes in the redux debug tool.
Following steps I have followed:
Installed Redux DevTool extension in chrome
Installed npm install --save-dev redux-devtools-extension
Configured this in App.js as follows
import { composeWithDevTools } from 'redux-devtools-extension';
const store = createStore(rootReducers, composeWithDevTools());
Pressed Control + M in emulator clicked on Start Debugging.
Reloaded the app.
Got Error
Error: EISDIR: illegal operation on a directory, read at Object.readSync (fs.js:592:3) at tryReadSync (fs.js:366:20) at Object.readFileSync (fs.js:403:19) at UnableToResolveError.buildCodeFrameMessage(/home/gaurav/reactproject/shopping/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:347:17) at new UnableToResolveError (/home/gaurav/reactproject/shopping/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:333:35) at ModuleResolver.resolveDependency (/home/gaurav/reactproject/shopping/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:211:15) at DependencyGraph.resolveDependency (/home/gaurav/reactproject/shopping/node_modules/metro/src/node-haste/DependencyGraph.js:413:43) at /home/gaurav/reactproject/shopping/node_modules/metro/src/lib/transformHelpers.js:317:42 at /home/gaurav/reactproject/shopping/node_modules/metro/src/Server.js:1471:14 at Generator.next (<anonymous>)
If debug mode is stopped, I don't get any error in the terminal. Following are dependencies in the project.
"dependencies": {
"#react-native-community/masked-view": "^0.1.10",
"#react-navigation/native": "^5.9.3",
"#react-navigation/stack": "^5.14.3",
"react": "17.0.1",
"react-native": "0.64.0",
"react-native-gesture-handler": "^1.10.3",
"react-native-reanimated": "^2.0.0",
"react-native-safe-area-context": "^3.2.0",
"react-native-screens": "^2.18.1",
"react-native-vector-icons": "^8.1.0",
"react-navigation-header-buttons": "^7.0.0",
"react-redux": "^7.2.2",
"redux": "^4.0.5"
},
"devDependencies": {
"#babel/core": "7.13.10",
"#babel/runtime": "7.13.10",
"#react-native-community/eslint-config": "2.0.0",
"babel-jest": "26.6.3",
"eslint": "7.14.0",
"jest": "26.6.3",
"metro-react-native-babel-preset": "0.64.0",
"react-devtools": "^4.10.1",
"react-test-renderer": "17.0.1",
"redux-devtools-extension": "^2.13.9"
},
In the emulator, I also got errors as showing in the screenshot.
It would be a great help if anyone could help in finding a solution to that.
Thanks.

uncaught TypeError: Cannot read property 'major' of undefined

I'm developing an android app with native java & react native. After updating the react native and the dependencies, whenever the development server scripts(locally ) were loaded into the device, it's giving the following error in the typical red screen:
com.facebook.react.common.JavascriptException: Uncaught TypeError: Cannot read property 'major' of undefined
loadApplicationScript
WebSocketJavascriptExecutor.java:173
run
NativeRunnable.java
handleCallback
Handler.java:836
My dependencies list : (from package.json)
"dependencies": {
"create-react-class": "^15.6.3",
"lodash": "^4.17.5",
"minutes-seconds-milliseconds": "^1.0.3",
"prop-types": "^15.6.1",
"react": "^16.3.0-alpha.2",
"react-native": "^0.54.2",
"react-native-carousel": "^0.11.0",
"react-native-checkbox": "^2.0.0",
"react-native-code-push": "^5.3.1",
"react-native-communications": "^2.2.1",
"react-native-deprecated-custom-components": "^0.1.2",
"react-native-elements": "^0.19.0",
"react-native-masked-text": "^1.6.5",
"react-native-modal-dropdown": "^0.6.2",
"react-native-modal-picker": "0.0.16",
"react-native-parsed-text": "0.0.20",
"react-native-selectbox": "^0.1.2",
"react-native-simple-radio-button": "^2.7.1",
"react-native-tab-view": "0.0.74",
"react-native-tabbed-view-pager-android": "^1.0.4",
"react-native-vector-icons": "^4.5.0",
"react-redux": "^5.0.7",
"react-timer-mixin": "^0.13.3",
"redux": "^3.6.0"},
"devDependencies": {
"babel-jest": "22.4.1",
"babel-preset-react-native": "4.0.0",
"babel-polyfill": "^6.26.0",
"jest": "22.4.2",
"react-native-bundle": "0.0.4",
"react-test-renderer": "16.2.0"},
In the JS console, it's giving following error :
Cannot read property 'major' of undefined
Failed to print error: regeneratorRuntime is not defined

Categories

Resources