However, the android emulator could not figure out the redirect uri, and that's because the android emulator and my PC are in different networks. localhost works on my PC, but the android emulator is its own network. The way to fix it is with adb reverse. Like this:
adb reverse tcp:44371 tcp:44371
The port number does not necessarily need to match, it can be different. The first port is the emulator's, and the second port is obviously your PC.