A good way to get rid of them in the kitchen is to put out a shallow bowl (or a jar lid works great) fill it to the brim with oil and vinegar and they are attracted and then get stuck. You have to fill it to the brim though or they just hang out on the edge and don’t fall in…...
It’s the oil that is unnecessary. Red wine, red vinegar, fly paper, and some other ideas plus scrupulous cleanliness and fruit under cover or in refrig.