hello! I had the same issue, I found my answer here on stack overflow
' Matrix < 1.6-2 and Matrix >= 1.6-2 are binary incompatible. When you change between them, you must re-install from sources packages that link Matrix and therefore depend on the Matrix "
tools::package_dependencies("Matrix", which = "LinkingTo", reverse = TRUE)[[1L]]
install.packages("lme4", type = "source")
hope that helps!