Lithology identification plays an essential role in geologic exploration and reservoir evaluation. In recent years, machine-learning-based logging lithology identification has received considerable attention due to its ability to fit complex models. Existing work develops machine-learning models under the assumption that the data gathered from different wells are from the same probability distribution, so that the model trained on data from old wells can be directly applied to predict the lithologies of a new well without losing accuracy. In fact, due to variations in sedimentary environment and well-logging technique, the data from different wells may not have the same probability distribution. Therefore, such a direct application is unreliable. To prevent the accuracy from being reduced by the distribution difference, we integrate the unsupervised domain adaptation method into lithology identification, under the assumption that no lithology labels are available on a new well. Specifically, we have developed a two-flow multilayer neural network. We train our network with a maximum mean discrepancy optimization, and the training process is interrupted by an early stopping criterion. These methods ensure that the feature representations learned by our network are domain invariant and discriminative. Our method is evaluated from multiple perspectives on a total of 21 wells located in the Jiyang depression, Bohai Bay Basin. The experimental results demonstrate that our method effectively mitigates the performance degradation caused by data distribution differences and outperforms the baselines by approximately 10%.