The 38-year old won the Champions League with Inter Milan in 2010 and was Brazil's goalkeeper at the 2010 and 2014 World Cups.
Flamengo already have Diego Alves, another former Brazil keeper, on their books.
(Reporting by Andrew Downie; Editing by Christian Radnedge)