I read a book about 20 years ago. It's about an actor who plays a starship captain in series like Star Trek, who gets kidnapped by real aliens and they replace him on Earth with an Android. They also put him in a machine that repaired his body at the molecular level. The book was science fiction with humor.
The novel is "Diplomatic Act" by Peter Jurasik & William H Keith Jr. copyright 1998.
Richard Faraday didn't believe in aliens, even though he played one on TV. Unfortunately, the aliens believe in him ... or rather, they believe in Harmon, the alien diplomat Faraday plays on the SF program Star Peace. A war is threatening to tear the civilized galaxy apart, and only a diplomat as superb as Harmon can stop it. The problem is that the real aliens are just a little confused about the bizarre human concept known as fiction. They think Harmon is real....Well, real or not, "Harmon" had better solve their alien problems fast or Faraday, galactic civilization and Earth itself will be abruptly canceled.
A good novel that is very similar to and released a year before the Galaxy Quest novel / movie.
While not a perfect match, perhaps the novelization of the 1999 movie Galaxy Quest?
"In November 1999, Galaxy Quest was novelized by science fiction writer Terry Bisson, who stayed very close to the plot of the film."
Points that match:
Read a book about 20 years ago.
It's about an actor who plays a starship captain in this series like star trek
Check. Tim Allen plays Jason Nesmith a.k.a. (Cmdr. Peter Quincy Taggart) from the fictional show Galaxy Quest on the ship the NSEA Protector. Galaxy Quest is a loose Star Trek parody.
who gets kidnapped by real aliens
Check. Unaware that they are truly octopoidal aliens, using technology to appear human, the barely conscious Nesmith is oblivious to his limo being beamed aboard the Thermian's spaceship.
and they replace him on Earth with an Android. They also put him in a machine that repaired his body at the molecular level.
No match. I don't remember this from the movie though it has been a few years. However, perhaps this might be related to the scene in which Allen as Commander Taggart is molecularly transported back to Earth? Or, perhaps the novelization might have deviated just a bit from the movie? As I recall, Allen's character was rather inebriated when he was kidnapped. Perhaps the Thermians had to sober him up quickly in the book.
The book was science fiction with humor.
Check. Galaxy Quest is a 1999 American comedy science fiction film directed by Dean Parisot and written by David Howard and Robert Gordon. Mark Johnson and Charles Newirth produced the film for DreamWorks.