0

我有一个问题,我根据appodeal-android-demo在我的项目中添加了appodeal 2.0.2 ,并且在进行测试时一切正常,在我的项目中我只使用原生广告,我唯一的问题是当我生成了发布签名的 apk,当我点击广告时,应用程序会崩溃并向我显示这些日志,有什么帮助吗?,谢谢!

08-24 16:31:36.856 23468-23468/? E/AndroidRuntime: FATAL EXCEPTION: main
                                                   Process: com.DennisTest.app, PID: 23468
                                                   android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
                                                       at android.view.ViewRootImpl.setView(ViewRootImpl.java:680)
                                                       at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:288)
                                                       at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69)
                                                       at android.app.Dialog.show(Dialog.java:312)
                                                       at android.app.ProgressDialog.show(ProgressDialog.java:116)
                                                       at android.app.ProgressDialog.show(ProgressDialog.java:99)
                                                       at android.app.ProgressDialog.show(ProgressDialog.java:94)
                                                       at com.appodeal.ads.native_ad.d$a.a(Unknown Source)
                                                       at com.appodeal.ads.ah.onClick(Unknown Source)
                                                       at android.view.View.performClick(View.java:5156)
                                                       at android.view.View$PerformClick.run(View.java:20755)
                                                       at android.os.Handler.handleCallback(Handler.java:739)
                                                       at android.os.Handler.dispatchMessage(Handler.java:95)
                                                       at android.os.Looper.loop(Looper.java:145)
                                                       at android.app.ActivityThread.main(ActivityThread.java:5835)
                                                       at java.lang.reflect.Method.invoke(Native Method)
                                                       at java.lang.reflect.Method.invoke(Method.java:372)
                                                       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
                                                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
08-24 16:31:37.216 955-24913/? E/android.os.Debug: !@Dumpstate > sdumpstate -k -t -z -d -o /data/log/dumpstate_app_error
4

1 回答 1

0

让我支持 Appodeal 的解决方案是它需要活动的上下文而不是项目:

View providerView = nativeAd.getProviderView(container.context); //---- linear layout parent container from cardView
   if (providerView != null) {
       container.addView(providerView);
   }
   nativeAd.registerViewForInteraction(cardView);
@Override
   protected BaseItemView onCreateItemView(ViewGroup parent, int viewType) {
       ListAdaptersViewTypes type = ListAdaptersViewTypes.values()[viewType];
       switch (type) {
           case AD:
//                return AdItemView_.build(App.context);  // before Aplication context
               return AdItemView_.build(parent.getContext()); // now Activity context
           default:
               return ItemView_.build(App.context, new CustomItemViewListener());
       }
   }

你可以根据这个答案复习:https ://github.com/appodeal/appodeal-android-demo/issues/5

于 2017-09-01T19:16:38.177 回答