"I have decided to stop playing professional football. It is a very hard moment but I am happy with my decision. My health comes first," said Aguero, who enjoyed 10 highly successful years at Manchester City before leaving at the end of last season.
He signed a two-year deal with Barcelona but had made just five appearances, scoring one goal against Real Madrid, before being taken to hospital with breathing problems after a match at home to Alaves in October.
Aguero was then diagnosed with a heart problem and forced to accept that he would not be able to play again.
"I took this decision because of problems I had a bit more than a month ago. I was in good hands with the doctors who also did their best and told me the best thing to do was stop playing," he said at the press conference at the Camp Nou, which was attended by his Barcelona team-mates.
"I did everything possible to keep the hope alive but there wasn't much hope."
Aguero began his career at Independiente in his native Argentina before moving to Europe in 2006 to sign for Atletico Madrid.
He won the Europa League during his time with the Spanish side and then moved to City in 2011.
Aguero left the Etihad Stadium a decade later as their all-time leading scorer with 260 goals, the most famous being his injury-time strike against Queens Park Rangers in May 2012 which won the Premier League title.
"I am very proud of the career I have had," he added.
"Everyone knows about the goal I scored for City against Queens Park Rangers to win my first Premier League, but there have been many great moments."