It's more complicated than that. The Church didn't so much "attack" it, as not accept it as a proven fact, and not allow it to be presented as such. They favoured the mathematically equivalent model of Tycho Brahe (which is just a coordinate change from the Copernicus model, unlike earlier geocentric models). They did allow heliocentrism to be presented as an unproven hypothesis.
The heliocentrism model was only proven by the successive efforts of Kepler and Newton. Kepler made it more accurate by formulating his laws of motion (which allow for an elliptical motion and eliminate the last need for epicycles), and Newton showed how Kepler's laws of motion could be derived from F = GMm/d^2. Kepler was a contemporary of Galileo, and Newton came later.
Regarding the treatment of Galileo, Galileo was on very good terms with the Roman Church until he openly insulted geocentrism proponents in a book, and presented the heliocentrism theory as a proven fact. The book is also notable for presenting an incorrect theory of tides, not giving credit to his contemporaries, omitting the more accurate and profound theory of Kepler, and attacking a strawman that nobody was defending (in the sense that the favoured model of the time was Brahe's, and not the complicated epicycles model that Galileo was attacking).