0

I have an issue, I added appodeal 2.0.2 according to the appodeal-android-demo to my project and everything is working correctly when doing test, in my project I'm using only native ads,the only problem I have is that when I generated the release signed apk, when I click on an ad, the application Does crash and shows me these logs, any help that can be?, Thanks!

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
user_Dennis_Mostajo
  • 2,279
  • 4
  • 28
  • 38

1 Answers1

0

the solution that gave me support of Appodeal was that it needed the context of the activity and not the project:

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());
       }
   }

You can review according to this answer:https://github.com/appodeal/appodeal-android-demo/issues/5

user_Dennis_Mostajo
  • 2,279
  • 4
  • 28
  • 38