Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native app not building for Android - SyntaxError: \u can only be followed by a Unicode character sequence

My App is running fine on iOS but will not run on Android. I spent ages last week getting it working, and thought it was , and the problem has returned.

enter image description here

Logs show enter image description here

Full logs here in case there is other stuff relevant. https://pastebin.com/by6uCmPW

SyntaxError: \u can only be followed by a Unicode character sequence 

When I reload I then get a white screen, no errors are shown, and I can't get past this, and it does not change whether i connect to the debugger or not.

enter image description here

I've looked at the source and the error is coming from the following line

enter image description here

Which is this from the React Native source https://github.com/facebook/react-native/blob/a974c140db605ecbdf8d3faa7a079b7e2dcebb09/Libraries/ReactNative/YellowBox.js#L263

After refreshing, I get the following error in logcat, although nothing in the emulator.

06-14 13:52:10.467: E/art(2691): No implementation found for com.facebook.react.bridge.Inspector com.facebook.react.bridge.Inspector.instance() (tried Java_com_facebook_react_bridge_Inspector_instance and Java_com_facebook_react_bridge_Inspector_instance__)

like image 509
Tom Avatar asked Nov 08 '22 20:11

Tom


1 Answers

Ok, I had the same issue and this is the solution I came up with that in order to make it work, I've added console.disableYellowBox = true; to index.android.js after the all imports lines.


As per React Native docs

YellowBoxes can be disabled during development by using console.disableYellowBox = true;. Specific warnings can be ignored programmatically by setting an array of prefixes that should be ignored: console.ignoredYellowBox = ['Warning: ...'];.

RedBoxes and YellowBoxes are automatically disabled in release (production) builds.


It's not an ideal workaround and probably still require some tinkering but by doing that I was able to compile the app.

Then in order to go a couple of steps deeper, I removed the recent addings (console.disableYellowBox = true; from index.android.js) and replaced {stacktraceVisible ? '\u{25BC}' : '\u{25B6}'} Stacktrace from \src\node_modules\react-native\Libraries\ReactNative\YellowBox.js with one of those next things:

  • {stacktraceVisible ? '\u25BC' : '\u25B6'} Stacktrace
  • {stacktraceVisible ? '-' : '-'} Stacktrace

It seems to fix the problem but not sure how elegant this way is and how you would be able to update every time after yarn or npm i.

like image 148
ummahusla Avatar answered Nov 15 '22 10:11

ummahusla