The kitchn's got some great tips. This one, for example:
a trick to get rid of fruit flies.
Honestly, can someone not be annoyed by them in summertime?
With this little simple trick problem is solved. Or at least diminishes a lot:
You pour some apple vinegar in a cup, add one or two drops liquid detergent, and place it next to the fruit bowl. Done.
(I have also tested white vinegar and rice vinegar; apple works a zillion times better)
Vinegar attracts them, detergent kills them. That's it.
The picture below is disgusting, but I'm publishing it so you can see it really works.
Depending on the quantity of flies that usually appear in your kitchen, it's nice to change the vinegar mixture once a day or once a week.
Also, I'd recommend choosing a ceramic cup or any other non-transparent material, to avoid making your kitchen look bad.
PS: I have tested using a piece of neutral soap, because that's what I have at home and use to wash my dishes, but it didn't do well like the detergent did.