I have two G5s and have had no problems with either. The lens protraction and autofocus mechanisms are robust enough for most handling, but they are fine mechanics. Could be you inadvertantly did something you were unaware of during handling that got the mechanism out of whack, but it could also be a production fault.
You could very gently try to help the mechanism ratchet back in while turning the camera on. Take the lens cover off and gently grip the outer lens edge with your finger nails, pulling, twisting and rocking back and forth. It could also be that it is not the mechanics, but someting further inside in the electronics or motor.
I had something similar with a G2, don't know what the cause was, but after playing with it a bit it started working fine again and I never had another problem with it.
If gentle coaxing doesn't do anything, definitely bring it to Canon.