Time flies like an arrow, but fruit flies like a banana.
Even if there can't be any flying fruit, the sentence is grammatically correct. The reader usually confuses the word "flies" in the second half of the sentence with the verb form of "to fly." However, "flies" here is a plural form of an insect "fly."
So the sentence is, Time flies like an arrow, but the insects like fruit flies prefer bananas.