flutter_native_admob icon indicating copy to clipboard operation
flutter_native_admob copied to clipboard

I get a ClassNotFoundException when using flutter_native_admob

Open d0mmi opened this issue 3 years ago • 9 comments

When the App tries to display the ad i get an ClassNotFoundException:

E/MethodChannel#flutter/platform_views( 6591): android.view.InflateException: Binary XML file line #5 in com.araapp.ara_app:layout/native_admob_banner_view: Binary XML file line #5 in com.araapp.ara_app:layout/native_admob_banner_view: Error inflating class com.google.android.gms.ads.formats.UnifiedNativeAdView
E/MethodChannel#flutter/platform_views( 6591): Caused by: android.view.InflateException: Binary XML file line #5 in com.araapp.ara_app:layout/native_admob_banner_view: Error inflating class com.google.android.gms.ads.formats.UnifiedNativeAdView
E/MethodChannel#flutter/platform_views( 6591): Caused by: java.lang.ClassNotFoundException: com.google.android.gms.ads.formats.UnifiedNativeAdView
E/MethodChannel#flutter/platform_views( 6591): 	at java.lang.Class.classForName(Native Method)
E/MethodChannel#flutter/platform_views( 6591): 	at java.lang.Class.forName(Class.java:454)
E/MethodChannel#flutter/platform_views( 6591): 	at android.view.LayoutInflater.createView(LayoutInflater.java:815)
E/MethodChannel#flutter/platform_views( 6591): 	at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1006)
E/MethodChannel#flutter/platform_views( 6591): 	at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:961)
E/MethodChannel#flutter/platform_views( 6591): 	at android.view.LayoutInflater.rInflate(LayoutInflater.java:1123)
E/MethodChannel#flutter/platform_views( 6591): 	at android.view.LayoutInflater.inflate(LayoutInflater.java:656)
E/MethodChannel#flutter/platform_views( 6591): 	at android.view.LayoutInflater.inflate(LayoutInflater.java:534)
E/MethodChannel#flutter/platform_views( 6591): 	at com.nover.flutternativeadmob.NativeAdView.<init>(NativeAdView.kt:52)
E/MethodChannel#flutter/platform_views( 6591): 	at com.nover.flutternativeadmob.NativeAdView.<init>(NativeAdView.kt:23)
E/MethodChannel#flutter/platform_views( 6591): 	at com.nover.flutternativeadmob.NativePlatformView.<init>(FlutterNativeAdmobPlugin.kt:97)
E/MethodChannel#flutter/platform_views( 6591): 	at com.nover.flutternativeadmob.ViewFactory.create(FlutterNativeAdmobPlugin.kt:76)
E/MethodChannel#flutter/platform_views( 6591): 	at io.flutter.plugin.platform.SingleViewPresentation.onCreate(SingleViewPresentation.java:186)
E/MethodChannel#flutter/platform_views( 6591): 	at android.app.Dialog.dispatchOnCreate(Dialog.java:421)
E/MethodChannel#flutter/platform_views( 6591): 	at android.app.Dialog.show(Dialog.java:315)
E/MethodChannel#flutter/platform_views( 6591): 	at android.app.Presentation.show(Presentation.java:250)
E/MethodChannel#flutter/platform_views( 6591): 	at io.flutter.plugin.platform.VirtualDisplayController.<init>(VirtualDisplayController.java:95)
E/MethodChannel#flutter/platform_views( 6591): 	at io.flutter.plugin.platform.VirtualDisplayController.create(VirtualDisplayController.java:48)
E/MethodChannel#flutter/platform_views( 6591): 	at io.flutter.plugin.platform.PlatformViewsController$1.createVirtualDisplayForPlatformView(PlatformViewsController.java:207)
E/MethodChannel#flutter/platform_views( 6591): 	at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.create(PlatformViewsChannel.java:104)
E/MethodChannel#flutter/platform_views( 6591): 	at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.onMethodCall(PlatformViewsChannel.java:59)
E/MethodChannel#flutter/platform_views( 6591): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
E/MethodChannel#flutter/platform_views( 6591): 	at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
E/MethodChannel#flutter/platform_views( 6591): 	at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:818)
E/MethodChannel#flutter/platform_views( 6591): 	at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#flutter/platform_views( 6591): 	at android.os.MessageQueue.next(MessageQueue.java:336)
E/MethodChannel#flutter/platform_views( 6591): 	at android.os.Looper.loop(Looper.java:174)
E/MethodChannel#flutter/platform_views( 6591): 	at android.app.ActivityThread.main(ActivityThread.java:7356)
E/MethodChannel#flutter/platform_views( 6591): 	at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#flutter/platform_views( 6591): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
E/MethodChannel#flutter/platform_views( 6591): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
E/MethodChannel#flutter/platform_views( 6591): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.ads.formats.UnifiedNativeAdView" on path: DexPathList[[zip file "/data/app/com.araapp.ara_app-QtmvM_hijlpxjPpcLK-2yA==/base.apk"],nativeLibraryDirectories=[/data/app/com.araapp.ara_app-QtmvM_hijlpxjPpcLK-2yA==/lib/x86, /data/app/com.araapp.ara_app-QtmvM_hijlpxjPpcLK-2yA==/base.apk!/lib/x86, /system/lib, /system/product/lib]]
E/MethodChannel#flutter/platform_views( 6591): 	at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:196)
E/MethodChannel#flutter/platform_views( 6591): 	at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
E/MethodChannel#flutter/platform_views( 6591): 	at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
E/MethodChannel#flutter/platform_views( 6591): 	... 31 more

I am using version flutter_native_admob: "2.1.0+3" i have these dependencies in the android/build.gradle

dependencies {
        classpath 'com.android.tools.build:gradle:4.1.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.0'
    }

i have the apply plugin at the end of the app/build.gradle: apply plugin: 'com.google.gms.google-services' and i have a correct APPLICATION_ID in the Android Manifest and a valid adUnitID for the nativeAd am i still missing something?

d0mmi avatar Apr 13 '21 10:04 d0mmi

Facing same issue here !🤔🧐

ghost avatar May 12 '21 13:05 ghost

Hi @d0mmi, are you using google_mobile_ads package in your app?

sanchaykasturey avatar May 27 '21 14:05 sanchaykasturey

Hi @d0mmi, are you using google_mobile_ads package in your app?

no, should i? i use:

  expandable: ^5.0.1
  awesome_dialog:
  titled_navigation_bar: ^4.1.0
  http: 0.13.0
  cached_network_image:
  shared_preferences:
  swipe_stack: ^1.0.0
  firebase_core:
  firebase_analytics:
  flutter_native_admob: "2.1.0+3"
  carousel_slider: ^2.2.1

d0mmi avatar May 27 '21 15:05 d0mmi

Hi @d0mmi, are you using google_mobile_ads package in your app?

no, should i? i use:

  expandable: ^5.0.1
  awesome_dialog:
  titled_navigation_bar: ^4.1.0
  http: 0.13.0
  cached_network_image:
  shared_preferences:
  swipe_stack: ^1.0.0
  firebase_core:
  firebase_analytics:
  flutter_native_admob: "2.1.0+3"
  carousel_slider: ^2.2.1

You can use it for native ads, its just complex as compared to what you will be doing with this package but it works. You can use it.

sanchaykasturey avatar May 27 '21 15:05 sanchaykasturey

You can use it for native ads, its just complex as compared to what you will be doing with this package but it works. You can use it.

Yeah i wanted to avoid that, but if i can not fix this error i will switch to that

d0mmi avatar May 27 '21 15:05 d0mmi

@d0mmi hi bro, i have the same problem here.... How you fixed it?

ramonpaolo avatar Jul 12 '21 02:07 ramonpaolo

@d0mmi hi bro, i have the same problem here.... How you fixed it?

I could not fix it

d0mmi avatar Jul 12 '21 05:07 d0mmi

@d0mmi, @ramonpaolo @hussam132 There are plenty of forks where this problem (and some others) are fixed. You can try from my copy.

hicnar avatar Sep 12 '21 16:09 hicnar

@d0mmi, @ramonpaolo @hussam132 There are plenty of forks where this problem (and some others) are fixed. You can try from my copy.

hi @hicnar thank you, this fix my problem :D

frostextreme11 avatar Sep 15 '21 11:09 frostextreme11