我正在尝试在Xamarin中为MoPub创建一个绑定库。实际上我的工作很棒。但现在我想实施调解。我已将GooglePlayServicesBanner.java文件添加到mopub SDK和Google Play服务库中:
compile 'com.google.android.gms:play-services:9.4.0'
但无论我做什么,绑定库都找不到“AdListener”
1>JARTOXML : warning J2X9001: Couldn't load class com/mopub/mobileads/GooglePlayServicesBanner$AdViewListener : java.lang.NoClassDefFoundError: com/google/android/gms/ads/AdListener
以下是可能发生这种情况的几个原因:
我被困住了,希望有人有一些见解。谢谢!
尝试显示Admob广告时,以下是Xamarin堆栈跟踪。
12-08 15:26:32.886 D/MoPub ( 3378): Loading custom event adapter.
12-08 15:26:32.886 D/MoPub ( 3378): Attempting to invoke custom event: com.mopub.mobileads.GooglePlayServicesBanner
12-08 15:26:32.891 I/art ( 3378): Rejecting re-init on previously-failed class java.lang.Class<com.mopub.mobileads.GooglePlayServicesBanner$AdViewListener>: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/ads/AdListener;
12-08 15:26:32.891 I/art ( 3378): at java.lang.Class java.lang.Class.classForName!(java.lang.String, boolean, java.lang.ClassLoader) (Class.java:-2)
12-08 15:26:32.891 I/art ( 3378): at java.lang.Class java.lang.Class.forName(java.lang.String, boolean, java.lang.ClassLoader) (Class.java:400)
12-08 15:26:32.891 I/art ( 3378): at java.lang.Class java.lang.Class.forName(java.lang.String) (Class.java:326)
12-08 15:26:32.891 I/art ( 3378): at com.mopub.mobileads.CustomEventBanner com.mopub.mobileads.factories.CustomEventBannerFactory.internalCreate(java.lang.String) (CustomEventBannerFactory.java:20)
12-08 15:26:32.891 I/art ( 3378): at com.mopub.mobileads.CustomEventBanner com.mopub.mobileads.factories.CustomEventBannerFactory.create(java.lang.String) (CustomEventBannerFactory.java:11)
12-08 15:26:32.891 I/art ( 3378): at void com.mopub.mobileads.CustomEventBannerAdapter.<init>(com.mopub.mobileads.MoPubView, java.lang.String, java.util.Map, long, com.mopub.common.AdReport) (CustomEventBannerAdapter.java:61)
12-08 15:26:32.891 I/art ( 3378): at com.mopub.mobileads.CustomEventBannerAdapter com.mopub.mobileads.factories.CustomEventBannerAdapterFactory.internalCreate(com.mopub.mobileads.MoPubView, java.lang.String, java.util.Map, long, com.mopub.common.AdReport) (CustomEventBannerAdapterFactory.java:32)
12-08 15:26:32.891 I/art ( 3378): at com.mopub.mobileads.CustomEventBannerAdapter com.mopub.mobileads.factories.CustomEventBannerAdapterFactory.create(com.mopub.mobileads.MoPubView, java.lang.String, java.util.Map, long, com.mopub.common.AdReport) (CustomEventBannerAdapterFactory.java:24)
12-08 15:26:32.891 I/art ( 3378): at java.lang.Object java.lang.reflect.Method.invoke!(java.lang.Object, java.lang.Object[]) (Method.java:-2)
12-08 15:26:32.891 I/art ( 3378): at java.lang.Object com.mopub.common.util.Reflection$MethodBuilder.execute() (Reflection.java:71)
12-08 15:26:32.891 I/art ( 3378): at void com.mopub.mobileads.MoPubView.loadCustomEvent(java.lang.String, java.util.Map) (MoPubView.java:188)
12-08 15:26:32.891 I/art ( 3378): at void com.mopub.mobileads.AdViewController.loadCustomEvent(com.mopub.mobileads.MoPubView, java.lang.String, java.util.Map) (AdViewController.java:177)
12-08 15:26:32.891 I/art ( 3378): at void com.mopub.mobileads.AdViewController.onAdLoadSuccess(com.mopub.network.AdResponse) (AdViewController.java:136)
12-08 15:26:32.891 I/art ( 3378): at void com.mopub.mobileads.AdViewController$1.onSuccess(com.mopub.network.AdResponse) (AdViewController.java:107)
12-08 15:26:32.891 I/art ( 3378): at void com.mopub.network.AdRequest.deliverResponse(com.mopub.network.AdResponse) (AdRequest.java:310)
12-08 15:26:32.891 I/art ( 3378): at void com.mopub.network.AdRequest.deliverResponse(java.lang.Object) (AdRequest.java:46)
12-08 15:26:32.891 I/art ( 3378): at void com.mopub.volley.ExecutorDelivery$ResponseDeliveryRunnable.run() (ExecutorDelivery.java:99)
12-08 15:26:32.891 I/art ( 3378): at void android.os.Handler.handleCallback(android.os.Message) (Handler.java:751)
12-08 15:26:32.891 I/art ( 3378): at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:95)
12-08 15:26:32.891 I/art ( 3378): at void android.os.Looper.loop() (Looper.java:154)
12-08 15:26:32.891 I/art ( 3378): at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6077)
12-08 15:26:32.891 I/art ( 3378): at java.lang.Object java.lang.reflect.Method.invoke!(java.lang.Object, java.lang.Object[]) (Method.java:-2)
12-08 15:26:32.891 I/art ( 3378): at void com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run() (ZygoteInit.java:865)
12-08 15:26:32.891 I/art ( 3378): at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:755)
12-08 15:26:32.891 I/art ( 3378): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.ads.AdListener" on path: DexPathList[[zip file "/data/app/com.kellyproductions.minechatlite-1/base.apk"],nativeLibraryDirectories=[/data/app/com.kellyproductions.minechatlite-1/lib/x86, /system/fake-libs, /data/app/com.kellyproductions.minechatlite-1/base.apk!/lib/x86, /system/lib, /vendor/lib]]
12-08 15:26:32.891 I/art ( 3378): at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:56)
12-08 15:26:32.891 I/art ( 3378): at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:380)
12-08 15:26:32.891 I/art ( 3378): at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312)
12-08 15:26:32.891 I/art ( 3378): at java.lang.Class java.lang.Class.classForName!(java.lang.String, boolean, java.lang.ClassLoader) (Class.java:-2)
12-08 15:26:32.891 I/art ( 3378): at java.lang.Class java.lang.Class.forName(java.lang.String, boolean, java.lang.ClassLoader) (Class.java:400)
12-08 15:26:32.891 I/art ( 3378): at java.lang.Class java.lang.Class.forName(java.lang.String) (Class.java:326)
12-08 15:26:32.891 I/art ( 3378): at com.mopub.mobileads.CustomEventBanner com.mopub.mobileads.factories.CustomEventBannerFactory.internalCreate(java.lang.String) (CustomEventBannerFactory.java:20)
12-08 15:26:32.891 I/art ( 3378): at com.mopub.mobileads.CustomEventBanner com.mopub.mobileads.factories.CustomEventBannerFactory.create(java.lang.String) (CustomEventBannerFactory.java:11)
12-08 15:26:32.891 I/art ( 3378): at void com.mopub.mobileads.CustomEventBannerAdapter.<init>(com.mopub.mobileads.MoPubView, java.lang.String, java.util.Map, long, com.mopub.common.AdReport) (CustomEventBannerAdapter.java:61)
12-08 15:26:32.891 I/art ( 3378): at com.mopub.mobileads.CustomEventBannerAdapter com.mopub.mobileads.factories.CustomEventBannerAdapterFactory.internalCreate(com.mopub.mobileads.MoPubView, java.lang.String, java.util.Map, long, com.mopub.common.AdReport) (CustomEventBannerAdapterFactory.java:32)
12-08 15:26:32.891 I/art ( 3378): at com.mopub.mobileads.CustomEventBannerAdapter com.mopub.mobileads.factories.CustomEventBannerAdapterFactory.create(com.mopub.mobileads.MoPubView, java.lang.String, java.util.Map, long, com.mopub.common.AdReport) (CustomEventBannerAdapterFactory.java:24)
12-08 15:26:32.892 I/art ( 3378): at java.lang.Object java.lang.reflect.Method.invoke!(java.lang.Object, java.lang.Object[]) (Method.java:-2)
12-08 15:26:32.892 I/art ( 3378): at java.lang.Object com.mopub.common.util.Reflection$MethodBuilder.execute() (Reflection.java:71)
12-08 15:26:32.892 I/art ( 3378): at void com.mopub.mobileads.MoPubView.loadCustomEvent(java.lang.String, java.util.Map) (MoPubView.java:188)
12-08 15:26:32.892 I/art ( 3378): at void com.mopub.mobileads.AdViewController.loadCustomEvent(com.mopub.mobileads.MoPubView, java.lang.String, java.util.Map) (AdViewController.java:177)
12-08 15:26:32.892 I/art ( 3378): at void com.mopub.mobileads.AdViewController.onAdLoadSuccess(com.mopub.network.AdResponse) (AdViewController.java:136)
12-08 15:26:32.892 I/art ( 3378): at void com.mopub.mobileads.AdViewController$1.onSuccess(com.mopub.network.AdResponse) (AdViewController.java:107)
12-08 15:26:32.892 I/art ( 3378): at void com.mopub.network.AdRequest.deliverResponse(com.mopub.network.AdResponse) (AdRequest.java:310)
12-08 15:26:32.892 I/art ( 3378): at void com.mopub.network.AdRequest.deliverResponse(java.lang.Object) (AdRequest.java:46)
12-08 15:26:32.892 I/art ( 3378): at void com.mopub.volley.ExecutorDelivery$ResponseDeliveryRunnable.run() (ExecutorDelivery.java:99)
12-08 15:26:32.892 I/art ( 3378): at void android.os.Handler.handleCallback(android.os.Message) (Handler.java:751)
12-08 15:26:32.892 I/art ( 3378): at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:95)
12-08 15:26:32.892 I/art ( 3378): at void android.os.Looper.loop() (Looper.java:154)
12-08 15:26:32.892 I/art ( 3378): at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6077)
12-08 15:26:32.892 I/art ( 3378): at java.lang.Object java.lang.reflect.Method.invoke!(java.lang.Object, java.lang.Object[]) (Method.java:-2)
12-08 15:26:32.892 I/art ( 3378): at void com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run() (ZygoteInit.java:865)
12-08 15:26:32.892 I/art ( 3378): at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:755)
答案 0 :(得分:1)
在编译之前,您必须在Xamarin绑定库中包含Google Play组件。这解决了这个问题。