id is not defined in the current scope (ApplovinMAX plugin ad callbacks)

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Maz90

Using Applovin Max plugin, Godot says id is not defined in the current scope when using callbacks with id argument.

Can you post the offending code?

jgodfrey | 2022-12-16 14:38

I’m using NativeLib by Dr. Moriarty.
applovin_max is in autoload.

loading interstitial (first arg should be replaced with ad unit id from Applovin MAX):

applovin_max.loadInterstitial("MAX AD UNIT ID", self.get_instance_id())

later function on loaded then show the ad:

func _on_interstitial_loaded(id):

finally call the function to show the ad (the id argument throws an error):


i followed a tutorial on youtube by finepointcgi and it worked fine for him.

Maz90 | 2022-12-16 16:30

So, you’re code is CALLING the _on_interstitial_loaded() function? I’m not familiar with this library, but I’d expect that function (presumably a callback) to be called by the library itself when the interstitial ad loads.

However, if you really are supposed to call it yourself, you’ll need to define some sort of id.

I assume this is the tutorial you watched:

Can you provide a video time code where Mitch is making the same _on_interstitial_loaded() call you show above?

jgodfrey | 2022-12-16 16:48

  • At about 34 minutes, he copies the ID for the interstitial ad from the AppLovin site.
  • At about 34:25, he creates a LoadInter() function to load an ad
  • That LoadInter() call is wired to his test button
  • That function calls the libraries loadInterstitial() function and passes the copied ID in.

It’s that loadInterstitial() call the triggers the _on_interstitial_loaded() callback and passes in the specified ID.

AFAIK, you shouldn’t be directly calling _on_interstitial_loaded()

jgodfrey | 2022-12-16 16:56

in minute 18:50 he only gives the ad is once to the applovin_max.loadBanner method. same when calling the loadInterstitial method.

I passed the id to the functions when i call them and it worked.
in the video he doesn’t pass the ad id when calling the functions.
now an error pops up when i run the game on a phone:

E 0:01:02.322 Java_org_godotengine_godot_GodotLib_calldeferred: Parameter “obj” is null.
<C++ Source> platform/android/java_godot_lib_jni.cpp:471 @ Java_org_godotengine_godot_GodotLib_calldeferred()

i’m not sure if its the Applovin plugin or smt else.

Maz90 | 2022-12-16 17:27

Looks like the code for that video is on GitHub, here. Maybe you can spot the difference there?

jgodfrey | 2022-12-16 17:32