This Bible contradiction is from the Skeptic's Annotated Bible.
They were given to Judah.
Joshua 15:20 View context
This [is] the inheritance of the tribe of the children of Judah according to their families.
They were given to Dan.
Joshua 19:40-41 View context
[And] the seventh lot came out for the tribe of the children of Dan according to their families.
And the coast of their inheritance was Zorah, and Eshtaol, and Ir-shemesh,