During the evolution of software, improper change operations may cause architecture erosion. Architecture erosion creates problems on evolutionary costs, software performance and software quality. Many methods have been proposed to analyze architecture erosion. Architecture depends on the implementation of code, that is, architecture erosion is caused by code. However, few methods analyze the reasons for architecture erosion based on code. Besides, architecture is eroded with software evolution, but most methods do not analyze architecture erosion based on the change of software. In this paper, we propose a multilevel analysis method for architecture erosion. Our method contains three steps. Firstly, we detect the changed pairs based on two architectures by performing a multilevel change detection method. Secondly, we detect whether the corresponding code elements of changed pairs are erosion points by calculating erosion degree. Thirdly, we establish a cost-benefit model of repairing architecture erosion for repairing architecture erosion more effectively with repaired few erosion points. We illustrate our method through an open source project, and the experimental results indicate that our method can detect the erosion points of each level and the cost-benefit model is effectively.