An adventure pours a vial of acid on an enemy combatant. I assume the enemy will try to avoid this.
How can this be handled with the rules of the game? How does this change if the acid vial is thrown?
This is written in the Player's Handbook on page 148:
Acid. As an action, you can splash the contents of the vial onto a creature within 5 feet of you or throw the vial up to 20 feet, shattering it on impact. In either case, make a ranged attack against a creature or object, treating the acid as an improvised weapon. On a hit, the target takes 2d6 acid damage.
Remember that a ranged attack in melee range gives you disadvantage, so that covers the part where the enemy is trying to avoid the attack.