-1

(quick backstory)

My friend and I are working on a react native project. He started development on iOS and the app builds successfully. Now I'm joining the fun by being the android guy.

After cloning, installing npm packages, and setting up adb for my device, the app installs on my phone by when I tap on it, it crashes. react-native run-android finishes with BUILD SUCCESSFUL.

Because I can't find any logs, I messed with the "working" (as far as iOS is concerned) version and introduced an error just so I can enable remote debugging from the device. Chrome opened a tab for me, the "React Native Debugger". This is what it says:

enter image description here

Error message: SyntaxError: Unexpected token u in JSON at position 0

Any ideas? My friend is stumped as well.

Edit 1: It's an aws-amplify issue (https://github.com/aws-amplify/amplify-js/issues/1276) but it doesn't say what the fix is

reiallenramos
  • 1,235
  • 2
  • 21
  • 29

1 Answers1

0

Try this in the console:

JSON.parse(undefined)

Here is what you will get:

Uncaught SyntaxError: Unexpected token u in JSON at position 0
    at JSON.parse (<anonymous>)
    at <anonymous>:1:6

In other words, your app is attempting to parse undefined, which is not valid JSON.

There are two common causes for this. The first is that you may be referencing a non-existent property (or even a non-existent variable if not in strict mode).

Sourcd: Uncaught SyntaxError: Unexpected token u in JSON at position 0

Also, it seems here might be an issue

federatedUser = JSON.parse(this._storage.getItem('aws-amplify-federatedInfo').user); 
Akash Pal
  • 1,055
  • 8
  • 15