Andrea Gioannetti was born in Bologna on January 6, 1722, the son of Baldassarre Francesco Gioannetti and Pellegrina Zanoni. His baptismal name was Melchiorre Benedetto Lucidoro Gioannetti.
In 1739, he joined the Order of Saint Benedict, Camaldolese at the monastery of Sant'Apollinare in Classe near Ravenna. He adopted "Andrea" as his religious name on June 29, 1739. He was then sent to study at Bertinoro and Rome, where he studied philosophy and theology.
He was ordained as a priest on December 19, 1744. After further studies in Bertinoro and Rome, Gioannetti returned to Bertinoro as its priest. On December 19, 1748, he returned to the monastery at Classe, becoming lector of philosophy. He later served as the theologian of Ferdinando Romoaldo Guiccioli, Archbishop of Ravenna, from June 15, 1753 until 1763. In 1763, he became procurator and economous of the monastery of Classe, later becoming its abbot in 1770. In 1773, he became abbot of the monastery of San Gregorio Magno al Celio in Rome. In this capacity, he served under Cardinal Giovanni Angelo Braschi, the monastery's commendatory abbot, who became Pope Pius VI in February 1775.
On January 29, 1776, he was elected titular bishop of Emeria and became administrator of the Archdiocese of Bologna. He was consecrated as a bishop by Cardinal Giovanni Francesco Albani, Bishop of Ostia, at San Gregorio Magno al Celio on February 4, 1776. He arrived in Bologna on March 5 and began a canonical visitation. As head of the Papal Legation, he was also the secular administrator of Bologna.
In the consistory of June 23, 1777, Pope Pius VI made Gioannetti a cardinal in pectore. This was published in the consistory of December 15, 1777, and Gioannetti received the red hat on December 18, 1777. He was awarded the pallium and the titular church of Santa Pudenziana on March 30, 1778.
In 1792, the Archdiocese of Bologna was overrun with Catholic priests fleeing the French Revolution. Cardinal Gioannetti subsequently wrote denouncing the revolutionaries. In June 1796, the French troops of Napoleon entered the Archdiocese of Bologna. Over the next several years, Gioannetti worked to secure the position of Catholicism as the state religion, a position recognized in the March 1797 constitution of the Cispadane Republic, but Catholicism's favored position was reversed when the Cispadane Republic was merged with the Cisalpine Republic in July 1797. In March 1799, Austrian and Russian troops occupied Bologna, enabling Gioannetti to reestablish his authority.
He participated in the papal conclave of 1799–1800 that elected Pope Pius VII. Shortly after returning to Bologna, he died on April 8, 1800. He is buried in Bologna Cathedral.