Home > OS >  Android Kotlin - AdView adSize: val cannot be reassigned
Android Kotlin - AdView adSize: val cannot be reassigned

Time:05-28

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

CodePudding user response:

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)
  • Related