TFT code works fine in uno but not in mega

i have build the program

But you have not shared the program.

giving error that sd card initialization fail.

So, you think that this problem is caused by the Mega, rather than your program not using the right pins or setting the mode of those pins correctly. Must be nice to be that naive.