Conflict between amsthm, cref, and hyperref [duplicate]

I cannot determine why this does not compile unless I remove amsthm which I normally include, though I don't exactly know why.

\documentclass{article}
\usepackage{amsthm}
\usepackage{mathtools, thmtools}

\usepackage[capitalize]{cleveref}

\declaretheorem[style=plain,numberwithin=section,name=Theorem]{theorem}
\declaretheorem[style=plain,sibling=theorem,name=Lemma]{lemma}
\usepackage{hyperref}

\begin{document}

\begin{theorem}
This is a test.
\end{theorem}

\begin{lemma}
This is a test.
\end{lemma}

\end{document}

• the cleveref package is one of the few packages which should be loaded after hyperref – user36296 Oct 25 '18 at 21:59
• The first error I get when I compile your code is "cleveref must be loaded after hyperref!". After doing that, the code compiles. Do you read your .log? – Werner Oct 25 '18 at 21:59