Lately I've been playing around with .sh scripting in Android. At first I used BusyBox and it's integrated scripting utility, though I quickly realised that coding on the phone isn't the best, so I switched over to my desktop and started using ADB to push my scripts to my device. It all worked well for about two weeks, until recently the exact same scripts that used to work perfectly, tell me some : not found[0]: syntax error: '{ Error. I've copied the exact same code from my script and used BusyBox to create it for me, and that way it works just fine. So the code is fine.
After some digging, I think it's either because of permissions, because of encoding possibly, or also because of the location of the scripts. I've tried many different locations (because I want to be able to run the scripts without root), and ended up choosing /storage/emulated/0. If I understood correctly, this is a symlink to the internal storage, which is read/write-able without root. But maybe sometimes executable and sometimes not? I don't know.
UPDATE: Thanks to @IrfanLatif, I've managed to fix the : not found[0]: syntax error: '{ Error! I was using Visual Studio Code as my editor for the scripts, which was saving them with the End of Line Sequence CRLF, which Android doesn't like. For an easy fix, just change your Line Endings to LF, problem solved. Check the comments out for more info.
You cannot browse this directory from a file manager on the phone, so a workaround is required to put your scripts there. I have created sub-directories from the home Termux directory, so it looks like this:
However, from here, you can access all the standard directories with read and write permissions (as well as create your own, of course). Here is the output from the tree command run from the home directory on my phone, which explains it better than words:
From my scripts directory I have written scripts called get.sh and put.sh to help move files between my PC and the phone, as it's easier to script on a PC's big screen. I use a hidden directory in the Download directory called ".scripts" as the point to access files on both my cable-connected PC and from Termux. All I have to do is make them executable once they are in the scripts directory.
I've had this same issue for a number of months now. I initially used @Jerry's solution however, this was a false resolution as it didn't fully fix the problem. Instead, what it did was take every build as a production build meaning that any slight change you made in the app would mean that rebuilding the entire app is necessary.
You can follow the instruction mentioned on the official page to fix this issue. This issue occur on real device because the JS bundle is located on your development system and the app inside your real device is not aware of it's location.
If there are two files i.e index.android.js and index.ios.js then run this react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
When you run react-native run-android, it runs adb reverse tcp:< device-port > tcp:< local-port > command to forward the request from your device to the server running locally on your computer.You will see something like this if adb is not found.
The problem is probably some port conflict (in my case it was the default IIS site that I completely forgot about). Another manifestation of the problem would be a failure to open :8081/debugger-ui URL in Chrome.
Edit:In the recent version of react-native they have fixed it. If you want complete freedom from this just uninstall node (For complete uninstallation Completely remove node refer this link) and reinstall node, react-native-cli then create your new project.
For android, most people use apps, like Flaming Durtles. There are certainly ways of getting regular scripts working on android using the Kiwi Browser, or any other, script capable browsers (firefox has t