No need to fear attacks just stay inside the attack screen (with/without attacking) and the enemy will not attack you. Luckily you can even upgrade your kingdom while in the attack screen!
Most of the time the upgrades take away resources that are not even required. For example. An upgrade that needs only 5,000 fish, will take away both my fish and all my "goat".