Example code provided in https://firebase.google.com/docs/admob/android/banner works fine for me using a given advertiser ID and ad size in xml file. But it is very important for me to be able to set advertiser ID and banner size based on certain parameters.
I considered these two but they did not work for me ->
Programatically set the AdMob id String and
How to specify adUnitId programmatically for AdMob?
When I try to implement second one I get errors when I try to link java file to xml file. How they should be linked?