React Native - Developer FAQ

Below are some problems I faced while learning and developing my first react native application. I kept referring to this list a lot for few other projects. Maybe it could also help others, so its not online.

Design

Architecture

Building for multiple architectures

Multiple actions from single action dispatcher

  1. http://jamesknelson.com/can-i-dispatch-multiple-actions-from-redux-action-creators/
  2. Example: src/actions/CreateNote.js:96 - a single fetch response is dispatching multiple actions one after another

Building

Could not get unknown property 'mergeResourcesProvider' for object of type com.android.build.gradle.internal.api.ApplicationVariantImpl

cannot use import statement outside a module (8Nov19)

    No answers

Vibrate the phone (wiggle/shake)

  1. `adb shell input keyevent 82`

Could not get unknown property 'javaCompileProvider' for object of type com.android.build.gradle.internal.api.LibraryVariantImpl.

Reset node/npm cache

  1. https://stackoverflow.com/questions/46878638/how-to-clear-react-native-cache
  2. `watchman watch-del-all && rm -rf $TMPDIR/react-* && rm -rf /tmp/haste-map-react-native-packager-* && rm -rf /tmp/metro-bundler-cache-* && rm -rf node_modules/ `
  3. Clear watchman watches: `watchman watch-del-all`.
  4. Delete the `node_modules` folder: `rm -rf node_modules && npm install`.
  5. Reset Metro Bundler cache: `rm -rf /tmp/metro-bundler-cache-*` or `npm start -- --reset-cache`.

Unit Testing

Cannot find module 'metro/src/reactNativeTransformer'

TypeError: Cannot read property 'default' of undefined

Conflict with dependency 'androidx.annotation:annotation' in project ':app'

    No answers

Actions must be plain objects. Use custom middleware for async actions.

    No answers

Mocking certain functions in a module

Detox Testing

Conflict with dependency 'androidx.annotation:annotation' in project ':app'. Resolved versions for app (1.0.0) and test app (1.1.0) differ.

Deployment and Google Play Release

version code is not changing in react native build release apk

Runtime

couldn't find DSO to load: libreactnativejni.so

Caused by: java.lang.RuntimeException: SoLoader.init() not yet called

  1. Happenned after upgrade from RN58 to RN61. Added to MainApplication with SoLoader call.

Your project is using deprecated "rnpm" config that will stop working from next release.

Cannot read Direction from undefined

  1. Had to move ios directory out and then run npx react-native link for automatic linking of everything

Cannot read property createNode of undefined

  1. Linking gesture and reanimated properly

navigator.geolocation.getCurrentPosition is undefined

ReactNative: ReactConfig: Could not find BuildConfig class

  1. When Proguard is enabled (which it is by default for Android release builds), it can rename the BuildConfig Java class in the minification process and prevent React Native Config from referencing it. To avoid this, add an exception to android/app/proguard-rules.pro: -keep class com.mypackage.BuildConfig { *; }

Unexpected token, expected ","

    No answers

Upgrading react-navigation to 5.x

Continuous delivery by Jenkins