On a Galaxy S8 I tried all the ideas presented in this thread but nothing worked. Finally the only method I found was to power-off the phone, then power-on without the charging cable connected (it does not start otherwise), then immediately after the logo is shown on the screen, plug the charging cable. There is no more moisture error after that and I could get normal charging (fast charging is not working in this way for some reason). Removing the cable and plugging it back in gives the same moisture error so for a recharge I need to start over with the power-off -> power-on cycle.