+4 votes

I am trying to show a rewarded video in my mobile game but it seems like I can't load the admob. I basically coppied the code from the Shin-Nil admob for Godot 3 example and made some alterations (link below)


The example project already works fine on my device, so I think it must be a problem in my project.

var admob = null
var isReal = false
var isTop = true
var adBannerId = "ca-app-pub-3940256099942544/6300978111" # test id
var adInterstitialId = "ca-app-pub-3940256099942544/1033173712" 
var adRewardedId = "ca-app-pub-3940256099942544/8691691433" 
var debug = null
var isbieunguloaded = false
var istrunggianloaded = false

func _ready():
        admob = Engine.get_singleton("AdMob")
        admob.init(isReal, get_instance_id())
        print("No admob singleton")

<Some code not relevant do ads>

# Loaders
func loadRewardedVideo():
    if admob != null:

# Events

func _on_BtnRewardedVideo_pressed():
    if admob != null:
        print("admob != null: showing video")
    print("null admob")

func _on_admob_network_error():
    print("Network Error")
        admob = Engine.get_singleton("AdMob")
        admob.init(isReal, get_instance_id())

func _on_rewarded_video_ad_loaded():
    print("Rewarded loaded success")

func _on_rewarded_video_ad_closed():
    print("Rewarded closed")

func _on_rewarded(currency, amount):
    print("Reward: " + currency + ", " + str(amount))
    #get_node("CanvasLayer/LblRewarded").set_text("Reward: " + currency + ", " + str(amount))

func _on_get_magnets_released():

When I run that project on my device, it Outputs "No admob singleton", so I can't initiate the admob variable (look at the if-else loop on the _ready function). Am I forgetting to do something.

I have spotted another problem: The projects settings for the example project that is working and my project are different, as seen in the image below. The android menu is missing. I am pretty sure this is causing the problem, but I don't know how to solve it.
enter image description here

I am sorry for any spelling errors, English is not my main language.

asked Dec 26, 2018 in Engine by Jonas Marma (18 points)

I can't help with your question but just wanted to say your English is really good, no need to apologise for it :)

Oh! Thank you!

Which version of godot are u using

It is Godot 3.0.6

2 Answers

0 votes

You must add the admob source code under the Godot Engine's modules directory, and compile it, and also compile the export template. Hope to help you!

answered Jan 3 by att (34 points)

can you explain in details? how n where i can find modules directory? i'm using mac version of godot

0 votes
answered Jul 23 by XxcringekidxX (27 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.