The effect of electrode resistivity on the in situ resistivity measurement in a diamond anvil cell was studied using finite element analysis. The theoretical analysis reveals that the origin of significant error for a thin sample is mainly caused by the resistivity difference between the electrodes and the sample. The authors found that reducing such resistivity differences can improve the accuracy. The result shows that the van der Pauw method [L. J. van der Pauw, Philips Tech. Rev. 20, 220 (1958)] can provide more accurate results for thin samples compared with the four-point probe method. This approach provides means to simulate actual experiments and to eliminate the measurement error.