Problem in ad manager

Is it mandatory to upload the app in an app store first to implement ads ?
Can’t we do this without uploading on an app store and doing that afterwards ?

remove all ads and then build the apk

No it’s not! You can use Ads from the very first version of your app. Setup ad components, then publish your app to Google Play! And, voila! Your app should be showing ad afterwards!

okay, so how test the app for ads ?
Should I switch on test mode ?