This paper shows that the WKB quantization rule is suitable for the Andreev bound states in nonuniform superconductors. We consider nonhomogeneous superconductivity gap functions $\mathrm{\ensuremath{\Delta}}(x)$ in superconductors with the Bogoliubov quasiparticle energy $E$, the Fermi level ${E}_{F}$, and the total momentum $\mathbf{p}$ at ${E}_{F}+E$. The Andreev bound states in the well of slowly varying $|\mathrm{\ensuremath{\Delta}}(x)|$ are studied, and the well may also be induced by the phase variation of $\mathrm{\ensuremath{\Delta}}(x)$ for massless Dirac fermions. By applying the WKB method to the Bogoliubov--de Gennes equation, we obtain two main results: (i) For ${E}_{F}\ensuremath{\sim}0$, the bound states are determined by ${\ensuremath{\int}}_{{L}_{E}}^{{R}_{E}}|\mathbf{p}\phantom{\rule{0.16em}{0ex}}d\mathbf{x}|=(\frac{1}{2}+n)\ensuremath{\pi}\ensuremath{\hbar}$, where $n\ensuremath{\in}{\mathbb{N}}_{0}$ and ${L}_{E}$ and ${R}_{E}$ are the boundary points between the classically allowed region and forbidden regions, and (ii) for ${E}_{F}\ensuremath{\gg}E$ and $|\mathrm{\ensuremath{\Delta}}(x)|$, the bound states are given by ${\ensuremath{\int}}_{{L}_{E}}^{{R}_{E}}|\mathbf{p}\ifmmode\pm\else\textpm\fi{}{\mathbf{p}}_{F}|dx=(\frac{1}{2}+n)\ensuremath{\pi}\ensuremath{\hbar}$ with small ${p}_{y(z)}$. Empirical quantization conditions are provided for broader parameter regions. In addition to applying the traditional WKB method, we also develop a generalized WKB method to tackle semimetals with parabolic dispersion relationships. The applications of our results are discussed, for example, Dirac $\ensuremath{\pi}$ junctions or nonchiral Majorana wires, SNS junctions, the excitation threshold, and the tunneling rate in NSN junctions. In the $\ensuremath{\pi}$ junction, the Majorana zero modes correspond to the zero-point energy in the WKB formalism. This observation may provide insights into the Majorana bound state in a vortex and the Majorana fermions in high-energy physics.