I was having a terrible time getting my Android phone and tablet to fully sync with my self-hosted Joplin server. They kept stopping and crashing out during the initial sync of my large notebook. My computers and iPad had no issues, but the Android devices failed every single time.
I tried every suggestion I could find, uninstalled and reinstalled multiple times, but nothing worked. Finally, I discovered a fix that allowed all my Android devices to sync perfectly. It actually came down to adjusting some settings in my reverse proxy.
If you use Nginx Proxy Manager, add these settings to the Advanced tab for your Joplin proxy host:
proxy_connect_timeout 600s;
proxy_send_timeout 600s;
proxy_read_timeout 600s;
send_timeout 600s;
client_max_body_size 1024m;
proxy_request_buffering off;
proxy_buffering off;
Why this works: By turning off buffering, your server sends the notes to your Android device as a constant stream rather than trying to "package" them. This keeps the connection "alive" in the eyes of the tablet/phone and prevents the 504 Gateway Timeout that often causes the crash.
I don't know if this will help everyone, but these settings in my reverse proxy allowed both my Android devices to finally complete the full initial sync. I still had to follow the other standard tips about keeping the devices awake during the process, but other than that, it was a success. It has been working flawlessly ever since.
Good luck!