I think you have a problem with assuming that the planet is earth like; Drop that and the situation becomes quite doable. If I were wanting to build a city that lasted ten million years my choice of location would be a planetoid that doesn't have a molten core and is geologically stable but large enough to have sufficient gravity so that the first generations are not inconvenienced by it.
As best as possible, ensure a stable orbit for the plant in question and then bore into it to its heavy metal rich core and build most of the support systems of the city deep in the interior powering the city with radioactive isotopes such as Uranium 235 (half-life of 700 million years). Leave the outer layers of the planet actually completely devoid of anything as a radiation and impact shield.
Of course, everything is going to have to be over engineered to be completely passive, as fool proof as possible, and automatic fail safes that depend on nothing themselves to function.
Which if the surface of the planet was also inhabitable, and earth like as specified but without active tectonics, then we get something like HG Wells Time Machine probably developing, actually quite possibly over multiple iterations over the time periods in question.
The building of the city itself would take long enough to, even if it didn't start this way, become a religion, and the city would last long enough that giants and gods were the builders of the city, even if the knowledge of how the city was built is not actually lost fully.