Least of Earth's problems. The distance between stars is so great that the collision between the Milky Way and Andromeda will be about them passing through each other then halting by gravity and merging. The probably of actual collisions, particularly on an outer spiral arm is very remote. There is a bigger risk of the Sun and its planets being ejected from the galaxy.
Either way, that event is still more than four billion years away. By then the Sun will be at the end of its life and swelling into a Red Giant if it hasn't already collapsed into a White Dwarf after engulfing Earth and charring it to a rocky crisp.
Long before then the Sun's power will have increased so much that all the water on Earth will have boiled away. This will happen within a billion years with life as we know it already long gone perhaps leaving only some kind of thermophile organisms if anything.
We would likely experience another large meteor impact on the scale of the C-T boundary Chixulub Event long before then if we don't manage to destroy ourselves even sooner.