"Then get rid of the foreign gods that are among you and offer your hearts to the Lord, the God of Israel." Joshua 24:23
The end of Joshua clearly anticipates the tragic events of the book of Judges. Here Joshua calls the Israelites to covenant faithfulness with God. After sternly warning them and challenging them to follow his example, he finds their profession of faith to be a testimony against them rather than a sign of faith. They promised not to worship other gods, but their shelves are lined with household idols. It's like a person on a diet stocking the pantry with Oreo cookies. If you are really going to worship God, then get rid of the idols.
Note also that Joshua calls them to "offer their hearts to the Lord." The first and most important sacrifice of God's people is a sacrifice of submission, of a heart that bows and bends to the will of the Almighty. We need both. Leave and cleave. Repent and believe. Joshua's call is a call to faithfulness, a call all God's people, both then and now, must answer.