Like If Metagross had the Steel gem and used Meteor mash then missed. Or had the ground gem and used Earthquake on a flying type. Or He uses any of them and the foe uses Protect.
The Gem won't disappear because the are only used up when doing damage. If a move misses, is ineffective, of is stopped by Protect/ Detect, the Gem won't disappear.
How to change your username
How to add a user avatar
Why was my post hidden?
Flags vs Downvotes
Official PokemonDb League
Type a Pokemon name, type, move or ability to see instant results.