The output flow ripple of the axial piston pump is one of the excitation sources for the hydraulic system vibration. The amplitudes of its specific harmonics must be reduced to avoid the resonance with the hydraulic pipeline. In this paper, a method on the nonuniform distribution of the pistons is put forward to adjust the flow ripple. The deflection angles of the pistons are used to describe the distribution rule. The distribution rule is imported to the Fourier expansion of the flow rate of each single-piston chamber, and then every single flow rate is superposed to obtain the Fourier coefficient of total flow rate that becomes the function of deflection angles. After this, objective optimization design is carried out to reduce the amplitudes of specific harmonics. Finally, the dynamic simulation model of the nonuniformly distributed axial piston pump is established to verify the effects of objective optimization. The results show that the amplitude of the ninth harmonic of the flow ripple can be reduced by about 40%, and the reductions are about 99% for the 18th and 27th harmonic.