After Jason Hanson spent 21 years as their kicker, the Detroit Lions needed just over 24 hours to replace him.

David Akers, released last month by San Francisco, reached a contract agreement Friday with the Lions.

Akers, entering his 16th NFL season, has been one of the league’s more dependable kickers throughout his career; however, he made just 29 of 42 attempts last season for the 49ers and was 9-of-19 from 40-plus yards.

Hanson hit on 32 of his 36 attempts last year.

At least part of the problem for Akers stemmed from a difficult recovery following a double-hernia operation. The injury apparently affected his accuracy. He underwent another minor surgical procedure last month to try to solve the problem.

Akers kicked a 63-yarder in the 2012 season opener but then missed at least one field goal in seven of San Francisco’s final nine games. He bounced back to kick three field goals in a Super Bowl loss to Baltimore. In 2011, Akers made 44-of-52 attempts.

Akers, 38, is four years younger than Hanson, who announced his retirement Thursday after contract negotiations with the Lions stalled. Akers made a visit to the Lions’ headquarters in Allen Park earlier this week.

He entered the NFL in 1998 after playing in college at Louisville. Akers spent one year with Washington, 12 years in Philadelphia and then the last two with San Francisco.