Guava trees produce sweet-smelling fruits with an edible rind and creamy white, yellow or pink flesh. Guavas thrive in tropical areas, but their adaptability allows them to survive a few degrees of frost in Mediterranean climates. When ripe, guavas emit a pungent, musky odor that attracts fruit flies. Fruit flies lay their eggs beneath the fruit’s skin, and the maggots feed on the flesh. The damage causes guavas to rot. Fruit fly infestations often spread quickly, but prompt treatment can get populations under control. Harvest guavas before they ripen fully. Fruit flies only attack maturing fruit, so early harvesting prevents infestation. Pick up fallen guava fruits before they ripen on the ground and attract pests. Monitor fruits for infestation. Tiny punctures that leak juice when the fruit is squeezed indicate infestation. A magnifying glass may help you look for damage. Cut open fruit to look for larvae. Seal infested fruits in a plastic bag. Leave the bag outside in the sun for several days, then dispose of it in the garbage.Make a fruit fly trap. Poke holes in the lid of a plastic container, then add 1 or 2 inches of apple cider or white wine vinegar to the container. Add one or two drops of unscented liquid dish soap. Set the trap near guava trees. The trap will lure fruit flies into the liquid, where they drown. Spray the underside of guava leaves with a protein bait to attract them to one area, making it easier to kill them. Use 40 milliliters of protein spray for every four guava trees. Reapply the spray each week. Apply a pesticide containing fenthion or dimethoate to infested trees. Mix the pesticide according to the directions on the container. Spray the foliage and fruit with 5 to 10 liters of the pesticide. Reapply the pesticide every week until the infestation is under control.