@demelos
I'm able to use Gmail IMAP and SMTP just fine when using v1.12.2 and PHP 7.2. Typically Invalid Credentials means you are not providing the correct credentials to the server for authentication. Do you have 2-Factor Authentication enabled? Do you have Lessecureapps enabled? Do you have DisplayUnlockCaptcha unlocked for the email account in question?
I would tail your server's logs to see where the connection is failing and get a more detailed error.
Cheers.