Nikhil
Nikhil

Reputation: 670

React Native Android app crashes while launching

enter image description here

My app crashed while launching. It is working fine in ios.

Package.json is below

{
  "name": "Leave",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest",
    "postinstall": "remotedev-debugger --hostname localhost --port 5675 --injectserver"
  },
  "dependencies": {
    "moment": "^2.18.1",
    "native-base": "2.1.1",
    "react": "16.0.0-alpha.6",
    "react-native": "0.43.4",
    "react-native-actionsheet": "^2.1.0",
    "react-native-elements": "0.10.3",
    "react-native-fs": "^2.1.0-rc.1",
    "react-native-i18n": "^1.0.0",
    "react-native-loading-spinner-overlay": "^0.4.4",
    "react-native-maps": "^0.15.2",
    "react-native-message-bar": "^1.6.0",
    "react-native-modal-datetime-picker": "4.2.1",
    "react-native-vector-icons": "4.0.0",
    "react-redux": "5.0.3",
    "redux": "3.6.0",
    "redux-thunk": "2.2.0",
    "superagent": "^3.5.2"
  },
  "devDependencies": {
    "babel-jest": "19.0.0",
    "babel-preset-react-native": "1.9.1",
    "flow-bin": "0.42.0",
    "jest": "19.0.2",
    "react-native-dotenv": "0.0.3",
    "react-test-renderer": "15.4.2",
    "remote-redux-devtools": "^0.5.10",
    "remote-redux-devtools-on-debugger": "^0.7.1"
  },
  "jest": {
    "preset": "react-native"
  }
}

Logs from logcat is given below

com.facebook.react.bridge.UnexpectedNativeTypeException: TypeError: expected dynamic type `int64', but had type `null'
                                                                 at com.facebook.react.bridge.ReadableNativeMap.getInt(Native Method)
                                                                 at com.facebook.react.devsupport.StackTraceHelper.convertJsStackTrace(StackTraceHelper.java:104)
                                                                 at com.facebook.react.devsupport.DevSupportManagerImpl$3.run(DevSupportManagerImpl.java:290)
                                                                 at android.os.Handler.handleCallback(Handler.java:739)
                                                                 at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                 at android.os.Looper.loop(Looper.java:148)
                                                                 at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                                 at java.lang.reflect.Method.invoke(Native Method)
                                                                 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

Please help.

I have try this https://github.com/facebook/react-native/issues/5646 but it was not working for me

Upvotes: 3

Views: 9358

Answers (2)

Nikhil
Nikhil

Reputation: 670

I found the problem the issue is with react-native-maps. Fix is given below

update

"react-native-maps": "^0.15.2"

to

"react-native-maps": "0.15.2".

Also I think "^" will cause problem in other dependencies in future. So I have removed them from my Package.json

Upvotes: 3

vincenth
vincenth

Reputation: 1792

I had the same problem, Nikhil's answer put me on the right track, unfortunately it was another dependency that was causing the crash.

It took me some time to pinpoint it, here is how I proceeded.

Step 1 : I removed every ^ before dependency's version number in package.json.

Step 2 : add ^ before ONE dependency's version number

Step 3 : remove dependency from node_modules and reinstall it (npm i)

Step 4 : restart package manager and restart application, if it starts without crashing, go to step 2

Optionnal step : Fix the dependency and send a merge request :)

Hope this helps.

Upvotes: 1

Related Questions