Skip to content
Advertisement

Issue in Native Ad Flutter using google_mobile_sdk

I want to monetise my Flutter app using google_mobile_ads library with Native ads. I am facing some issues while facing this documentation – https://developers.google.com/admob/flutter/native I am not sure where to put the my_native_ad.xml file so that it can be referred by the Kotlin Main Activity File.

Also, in the MainActivity file, I am facing some errors :-

  1. e: /Users/yash/AndroidStudioProjects/VideoPlayer/android/app/src/main/kotlin/dev/jideguru/filex/MainActivity.kt: (26, 5): ‘cleanUpFlutterEngine’ overrides nothing
  2. e: /Users/yash/AndroidStudioProjects/VideoPlayer/android/app/src/main/kotlin/dev/jideguru/filex/MainActivity.kt: (46, 113): No value passed for parameter ‘layoutInflater’
  3. e: /Users/yash/AndroidStudioProjects/VideoPlayer/android/app/src/main/kotlin/dev/jideguru/filex/MainActivity.kt: (83, 54): Unresolved reference: my_native_ad e: /Users/yash/AndroidStudioProjects/VideoPlayer/android/app/src/main/kotlin/dev/jideguru/filex/NativeAdFactoryExample.kt: (14, 58): Unresolved reference: R
  4. e:/Users/yash/AndroidStudioProjects/VideoPlayer/android/app/src/main/kotlin/dev/jideguru/filex/NativeAdFactoryExample.kt: (14, 58): Unresolved reference: R

Here is my MainActivity.kotlin file

JavaScript

Please let me know if any other details are required.

Advertisement

Answer

For those who are stuck on the same issue :-

list_tile_native_ad.xml :-

JavaScript

</com.google.android.gms.ads.formats.UnifiedNativeAdView>

MainActivity.kt :-

JavaScript

Keep your list_tile_native_ad.xml inside android/app/src/main/res/layout

NOTE :- I couldn’t add a dispose method because it kept throwing me an error.

Cheers!!

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement