Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Android Kotlin – AdView adSize: val cannot be reassigned

MobileAds.initialize(this) { }

val adViewBottom = AdView(this)
adViewBottom.adSize = AdSize.BANNER

This worked before I updated the library, now I get

val cannot be reassigned

on

adViewBottom.adSize

changing val to var doesn’t solve it

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Admob 21.0.0 changed the way to set ad size directly.
You can use the setAdSize method.

MobileAds.initialize(this) { }

val adViewBottom = AdView(this)
adViewBottom.setAdSize(AdSize.BANNER)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading