this mac can't connect to icloud because of a problem with gmail Every time I boot up I get the following error message on my mac mini:

This mac can't connect to icloud because of a problem with gmail

Open iClould preferences to fix this problem.

Each time I enter my password, but it comes again next boot.

I have read that others have had this issue, and the solution was to log out of icloud, and then log back in. I didn't this and it didn't work.

What can I do?

Thanks
Go to System Preferences > Internet Accounts. 

In the left pane, select the Google/GMail account.

Below the left pane, select "-" to delete the account. This won't delete the GMail account or whatever emails may be in it, but will terminate this Mac's ability to communicate with Google/GMail via the Apple Mail.app.

Sign out of iCloud. Wait a bit.

Sign back into iCloud.

Return to System Preferences > Internet Accounts. Select "Google" in the right pane, and re-enable the Google/GMail account on the Mac.