By *very* custom firmware I mean firmware that's *very* modified compared to standard ROMs.
In my view, MIUI falls into this category, esp. since device specific versions are often unofficial / unsupported by the original developers.
You're getting a connection error, that's a bad sign. It means the app isn't able to connect to Gmail's servers at all, before it even tries to authenticate (for example).
You mentioned a proxy, that could be an issue if it's not configured to pass through IMAP and SMTP ports (the standard GMail app's network protocol is HTTP based, so it would work as long as web browsing works).
Sorry can't be more of help, but I feel that your device / environment configuration is what's causing the original issue.