Ad Size and Ad unit id must be set before loadAd is called

后端 未结 8 1489
后悔当初
后悔当初 2020-12-03 00:52

I have this in my main xml file:



        
8条回答
  •  无人及你
    2020-12-03 01:13

    remove xmlns:ads="http://schemas.android.com/tools" from root view

    then add AdView

    
        
    

    Remember these steps:

    1. You can define xmlns:ads="http://schemas.android.com/apk/res-auto" on root view it self .

    2. if you have not defined xmlns:ads="http://schemas.android.com/apk/res-auto" inside rootView then you must need to add xmlns:ads="http://schemas.android.com/apk/res-auto" inside AdView.

    3. if you have defined adSize inside your AdView xml file then don't set dynamically, like : adView.setAdSize(AdSize.BANNER); or else it will through an exception java.lang.IllegalStateException: The ad size can only be set once on AdView.

    4. xmlns:ads="http://schemas.android.com/apk/res-auto" and xmlns:app="http://schemas.android.com/apk/res-auto" are looking same but there is a difference which is xmlns:ads and xmlns:app so don't get confuse.

    I think it will resolve your issue ... Happy to help :)

提交回复
热议问题