Maybe those would help (although using those would require changing how you do emails and it’s not a solution for Android):
offlineimap in case you need something to fetch your IMAP emails.
gmailieer is a tool which uses Gmail API to fetch emails.
notmuch is a tool which indexes your email. You can assign whatever labels you want and rather than folders it uses tags.
For notmuch you then need a front-end which can display the emails. I use Emacs for that. And since notmuch uses tags, you can then create whatever ‘folders’ by making saved searches.
Maybe those would help (although using those would require changing how you do emails and it’s not a solution for Android):