"You are unable to serve YHVH...he will not forgive..." in Joshua 24:19 was probably meant as a warning that God would not spare the nation the consequences of forsaking him. History proved him right. However God promises forgiveness *WHEN* (not if) they repent.
If you make a vow or oath to God, he will hold you accountable for keeping or violating it. Your words will be a witness against you.