Android v2ray complex config

None of the Android GUI app provides reliable support for complex v2ray config. They often come with simple single server configration, unbale to harness the power of balancer, chain, and routing function of the v2ray-core.

I managed to solve the problem in a linux fashion.

Install Termux, then

pkg install v2ray
tee ~/../usr/var/service/v2ray/run <<EOF
/data/data/com.termux/files/usr/bin/v2ray run -c /path/to/config.json
EOF

Finally use Sagernet to create VPN connecting to the local socks proxy, for all apps other than Termux.

The drawback of the method is that Termux is excluded from the VPN, and one will have to use other CLI tools like proxychains inside Termux. The problem roots in that one need to distinguish proxy traffic from normal traffic to avoid proxy loops. The method above uses the Termux app as a classifier.