A method for preparing nilotinib includes the following steps: performing an aminocarbonylation reaction on a compound A and 3-(4-methyl-1H-imidazole-1-yl)-5-(trifluoromethyl) aniline to obtain an amination product; and performing deprotection treatment of an R group on the amination product to obtain the nilotinib, wherein the compound A has a structure shown in formula I, and in formula I, an R group is selected from benzyl, —COCF3, —CHO or —CO2R′, where an R′ group is C1˜C10 alkyl, C1˜C3 alkoxy ethyl or C7˜C19 aralkyl.