We consider a generalization of the Rayleigh equation for the description of the dynamics of a spherical gas bubble oscillating near an elastic or rigid wall. We show that in the non-dissipative case, i.e. neglecting the liquid viscosity and compressibility, it is possible to construct the general analytical solution of this equation. The corresponding general solution is expressed via the Weierstrass elliptic function. We analyze the dependence of this solution properties on the physical parameters.