Heli was Joseph's Father-in-Law.
More of an explanation from gotquestions.org:
Matthew is following the line of Joseph (Jesus’ legal father), through David’s son Solomon, while Luke is following the line of Mary (Jesus’ blood relative), though David’s son Nathan. There was no Greek word for “son-in-law,” and Joseph would have been considered a son of Heli through marrying Heli's daughter Mary. Through either line, Jesus is a descendant of David and therefore eligible to be the Messiah.
I do appreciate the explanation, however even if there was no Greek word for son-in-law, Luke could have very easily communicated that Joseph is Heli's son through marriage to Mary, not simply call Joseph the son of Heli. Just because there is no exact word does not mean there was no way to communicate it.
Simply assuming that Heli must have been Mary's father without any other scriptural evidence is simply choosing an unlikely interpretation in an attempt to avoid admitting a contradiction.
Besides, many Christians say Mary's father was Joachim.