Unable to communicate to a local WiFi with mobile data enabled I'm developing an app that should work on a private WiFi network without Internet access. It's a controller for an interactive digital sculpture. The IP address of the server it should talk to on the private network is hardwired into the app.
I found that the app is unable to talk to the server on the WiFi as long as mobile data is enabled. As soon as I turn it off, everything works as expected. I guess for some reason it still tries to contact the server on the mobile data interface.
Here's the kernel IP routing table when both the WiFi and the mobile data is connected and the app doesn't work:
10.229.237.220/30 dev rmnet_data0 proto kernel scope link src 10.229.237.221 
192.168.26.0/24 dev wlan0 proto kernel scope link src 192.168.26.102 

With mobile data disabled and the app working correctly:
192.168.26.0/24 dev wlan0 proto kernel scope link src 192.168.26.102 

This seems all correct to me.
Are there any special settings (default gateway, nameserver, etc) I need to add to my network configuration so that the traffic from the app is routed to the WiFi interface? Any other ideas why it's not communicating with the server?
Android has an option to switch to cellular data if the wifi connection is low speed/signal. I suspect that the same mechanism triggers when the WiFi network does not have a default gateway defined, so all outgoing connections by default choose the source IP corresponding to the cellular interface.
To ensure you can talk to WiFi hosts where there is no internet connectivity, first query for the WiFi IP address then use it explicitly as the source IP in the app.
If you leave it default, ougoing connections would happen with the cellular IP address which then would go to the cellular gateway.
Alternatively, if you can root the device, you can then copy the tcpdump binary and capture the traffic over the WiFi and cellular interface to confirm the source IP of packets sent by your app. Instructions for this fall out of this question scope but here is a good how to: https://www.andreafortuna.org/2018/05/28/how-to-install-and-run-tcpdump-on-android-devices/