In the practical oilfield production, it has great significance to realize timely and accurate measurement of the moisture content of crude oil. However, there are some drawbacks in the traditional measurement methods, such as: non-real time, high cost, labor-consume, vulnerability to environmental impacts, and so on. In order to solve these problems, a soft sensor model based on multi-kernel Gaussian process regression optimized by an adaptive variable population fruit fly optimization algorithm (APFOA-MKGPR) is presented in this paper. A multiple kernels-based Gaussian process regression method is utilized to deal with the practical production process characterised by multiple operating phases, noises, strong nonlinearity and dynamic. In the multi-kernel function, many parameters (five hyper-parameters in the multi-kernel function and three weights of each kernel function) need to be accurately given, which is difficult to be effectively optimized by the maximum likelihood estimation. So, a swarm intelligence-based adaptive variable population fruit fly optimization algorithm (APFOA) is proposed to train the best model parameters. A novel adaptive variable population mechanism is developed to adaptively adjust the population size and the random flight distance during the iterations, which can realize a combination of the global searching and the local searching for the optimal solutions. The proposed method is verified by four benchmark functions and the actual production data of one oil well, and experimental results show the effectiveness for accurate prediction of the moisture content of crude oil.