The methods are listed in the order of risk of damaging your camera, so make sure that you try them in the listed order. And remember, these fixes (especially #6 and 7) should only be considered for a camera that's out of warranty, who's cost of repair would be excessive, and would otherwise be considered for disposal if unrepaired:
Fix #1: Remove the batteries from the camera, wait a few minutes. Put a fresh set of batteries back in (preferably rechargeable NiMH 2500mah or better) and turn the camera on. If using rechargeables, andt hey're more than a year old, consider purchasing new rechargeable batteries as they may not be providing sufficient power to startup the camera.
Fix #1a: If new batteries didn't work, try pressing and holding the Menu, Function, Function Set, or OK button while turning the camera on. This along with Fix #1c and #2 sometimes work for lens errors that occur from batteries wearing down while the lens was extended.
Fix #1c: For those of you who can still access your camera's menus with this error, try finding and selecting the "factory reset" option to set your camera back to its original factory condition. On some Canon cameras, this requires holding the menu button down with the camera powered on for up to 10 seconds. However note that a lens error might sometimes override the reset option, and thus the option might not appear.
Fix #2: If the camera's batteries ran down completely while its lens was still open, the camera may show a lens error or not start properly when new batteries are installed. Remove the memory card and keep it removed, then install the new batteries. When you turn the camera on with the card removed it may come back to life, as this triggers a reset in some cameras.
Fix #3: Insert the cameras Audio/Video (AV) cable, and turn the camera on. Inserting this cable ensures that the camera's LCD screen remains off during the start process. Thus extra battery power is available to the camera's lens motor during startup. This extra power can be useful in overcoming grit or sand particals that may be jamming the lens. If the AV cable doesn't fix the lens error by itself, consider keeping this cable installed while trying fixes 4, 5, and 7 as a means to provide extra power to help to these fixes. But note that I DON'T recommend keeping the cable installed during Fix 6 as you may damage the AV port while tapping the camera. Reinsert the cable only AFTER tapping the camera.
Fix #4: Place the camera flat on its back on a table, pointed at the ceiling. Press and hold the shutter button down, and at the same time press the power-on button. The idea is that the camera will try to autofocus while the lens is extending, hopefully seating the lens barrel guide pins back into their slots.
Fix #5: Blow compressed air in the gaps around the lens barrels with the idea of blowing out any sand or grit that may be in there jamming the lens. Other variations include blowing with a hair dryer in “no heat” setting, or sucking the gaps with a vacuum (careful with this one). Some people also have actually used a "Shop Vac" with this fix to help extend a retracted lens.
Now we're entering into the realm of potentially damaging your camera in conducting the fix. There is definitely some risk here, so take care when conducting the following fixes:
Fix #5a: If you actually do notice sand particles stuck in the gaps around the lens barrel, and blowing air does not help to dislodge them, consider using a thin piece of paper or a sewing needle to help dislodge them. Pay particular care not to scratch your lens barrel with the needle. Also, I do not recommend probing too deeply around the lens barrel with the paper (don't go more than a 1 cm or 1/2 in) . Particularly I do not recommend probing deeply around the most outer (largest) lens barrel gap, as you may dislodge the lens barrel dust gasket that's located just inside of that gap.
Dislodging Particles from Lens Barrel Gaps (Fix #5a)
Fix #6: Repeatedly tap the padded/rubber usb cover on a hard surface with the intent of dislodging any particles that may be jamming the lens. Other variations include hitting a side of the camera against the palm of your hand. A lot of people have reported success with this method. HOWEVER, there is also some obvious potential for damaging or dislodging internal components with this method, such as unseating ribbon cables, or cracking LCD screens.
Fix #6a: This is a variation of Fix #6, and should be tried if the lens barrels appears straight (not crooked). In other words, try this if there's no obvious mechanical damage to the lens barrels that's causing the problem. With the lens pointed down, try "gently" tapping around the lens barrels with a small item such as a pen or pencil. The idea is to try to dislodge any sand particles that may be jamming the lens barrel stuck. Simultaneously try turning the camera on and off as you're doing this.
Dislodging Particles by Tapping (Fix #6a)
Fix #7a: Note that this particular fix is intended only for cameras with lens barrels that try to extend, but then stop partway, and then return to their stored position. Try grabbing and holding the smallest inner lens barrel at its furthest extended position, preventing it from returning to the camera. Examine and clean around the lens barrel any noticed dust or dirt. Turn off and restart the camera again. If the lens extends even further, grab it again at its furthest extension, preventing it from returning. Clean again. Keep repeating until the lens is fully extended. Turn off the camera and restart it to see if the lens error has gone away.
Fix #7b: The most extreme of the fixes. Only consider this fix as an absolute last resort before tossing the camera, as there's some obvious potential for further damaging your camera by using this method. You especially might consider this if the lens barrel appears obviously damaged, bent, or crooked such as from a fall. In that case, try thinking of the lens as a dislocated shoulder. Try forcing the lens to straighten it and put it back in its place. In such cases, the lens barrel guide pins have become unseated from their guide slots (see the below illustration). Your objective would be to try to reseat them by straightening the lens. Listen for a "click" to hint that they've been reseated, and immediately stop forcing the lens at this point. More people have reported success with this method than with any of the other methods (see the polls in the right column).
Variations to Fix #7b include gently pulling, rotating, and/or twisting the lens barrel while hitting the power button. Examine the lens barrels closely for any hint of tilt or unevenness. Again, the goal is to attempt to straighten or align the barrel if it's crooked or twisted. Another variation includes looking for uneven gaps around the lens barrel, and then pushing on the side of the lens barrel that has the largest gap (note pushing the lens barrel all the way in is NOT recommended as it may become stuck there). Again, while doing any of the above, listen for a click that indicates that the lens barrel guide pins may have reseated in their guide slots. If you hear this click, immediately stop and try the camera. The following photo illustrates unseated guide pins that would cause a lens error.