[Construct 2] Rewarded Video plugin


Hi Ludei, I followed your documentation and prepared a Construct 2 plugin which allows to use Rewarded Video from Admob.

It works almost perfectly. I am able to start the video. Once the video ends, then the interstitial is shown (as intended) and once I close the interstitial I get the “reward” listener triggered so it’s good.

The problem is that during watching some rewarded videos there is a close button available to cancel the AD. When I click it and confirm that I want to cancel the video, the whole app crashes. My guess is that maybe there are some listeners I am not aware of or couldn’t find in the docs.

I have used the same listeners as for the interstitial (“show”, “load”, “click”, “fail” and “dismiss” - https://puu.sh/vAnud/98ef8cc2e6.png) and they do cover the final interstitial events. But dismissing the video while it plays is some other listener I believe which is not listed in the docs.

Could you please update the docs or at least let me know what’s the listener to handle canceling of the video?

Thank you
Toby R


I’m so happy to hear you working with this nice plugins!


Sorry for the late response @reenomt,

The plugin is public. Here you can see the code for the AdMob plugin for Android and here the common code to every Ads plugin from Cocoon.io. The later contains the code regarding listeners and we don’t have any other listener but those you used.

Do you have a log of the error that causes the crash?

Good luck.


Thanks for the reply. So I use the correct listeners, still the issue with crashing the app exists. I can’t run the app via debugger app because I’m using my own plugin for ads made based on your API (as your official C2 plugin does not have rewarded video feature), so I don’t have any error log.

I can send you my plugin or APK file or C2 test project if that helps. Rewarded videos are one of the most wanted feature for mobile devs so C2 community would very much appreciate the help with solving this issue.



What about the adb log? Could you post that for the moment?


Here’s the adb logcat result of launching the test app, starting the rewarded video and closing it while the video plays: crashlog.txt

The app id is com.wtfgg.rewardtest

I see some “crash” mentiones in the log and exceptions like this one “Attempt to write to field 'long com.ludei.ads.AdInterstitial$Reward.amount_’ on a null object reference_” yet I’m not the expert in interpreting those logs.

Also maybe you’ll find a useful information the fact that I have placed this plugin to the real app on Google Play and even though there are thousands of impressions of rewarded video, there is no income being generated at all from this ad. So it looks like some API is not being triggered even when the video is fully watched by the user.


Do you have the whole log of this? Also, is your plugin public?


I attached the full log in my previous post. The plugin is not public yet, I can send it to you, just let me know the email address.



I don’t see the line Attempt to write to field 'long com.ludei.ads.AdInterstitial$Reward.amount__' on a null object reference in the previous log.

You can send it to support@cocoon.io. Add a link to this thread for context. Thank you.


Ah sorry just tried it out and I somehow pasted it with change (?)… anyway the line is:

Attempt to write to field ‘long com.ludei.ads.AdInterstitial$Reward.amount’ on a null object reference

It’s line 13267 and 13241

I will send you the plugin shortly.

Email sent


I’ve updated our AdMob plugin with a fix that should resolve the crash.

The impressions without revenue are something different. If AdMob says you are having thousands of impressions but you don’t receive revenue that is an issue within AdMob.


Thanks for the update. I just gave it a try but received the compilation error. Should I implement any changes in my JS plugin as well (has the API changed?) or the fix was only on your side?


I have the same problem. After the last update


There was an issue with a dependency. It should be fixed by now.

Sorry for the inconveniences.


It works now. I succescully compiled the app and gave it a try. the issue with app crashing while cancelling the video is fixed, thanks.

There is another issue now. For obvious reason we need a way to determine if the video was fully watched or if it was cancelled.

Right now the this.rewardedVideo.on("reward", function(reward, error) triggers no matter if it’s fully watched or cancelled. So I’ve implemented additional check as described in the API as follows:

if (reward && reward.amount > 0) {
self.runtime.trigger(cr.plugins_.CocoonRewardedVideo.prototype.cnds.onRewardInterstitialSucceeded, self);
else {
self.runtime.trigger(cr.plugins_.CocoonRewardedVideo.prototype.cnds.onRewardInterstitialFailed, self);

Now no matter if it’s cancelled or fully watched the onRewardInterstitialFailed is triggeres which means that the if (reward && reward.amount > 0) condition is always false.

I see no additional info in the manuals/API about that. Not sure if it’s still something wrong on your side or should I implement some other condition?



Is the error parameter undefined?


I spent some longer while dbugging this. Your docs clearly say that “reward” is an object as you refer to “reward.amount” and I assumed that “error” is an object as well. This misslead me a lot. It turned out that “reward” is always a string, but the “error” is not always a string. Anyway after testing I managed to make a valid (I hope) condition and now I’m about to test it on the real app.

I will keep you updated if everything works fine now.

Thank you for your support so far :wink:


Awesomee!! hope it works! :smiley:


Any good news to hear @reenomt ? :smiley:


@reenomt I was waiting for such a plugin… does it actually work? is it publicly available?