I had this problem and used a can of air duster to spray the earphone jack and charging dock. Problem solved! : )
open