defold / extension-admob

Defold native extension which provides access to AdMob functionality on Android and iOS
https://www.defold.com/extension-admob/
MIT License
37 stars 12 forks source link

too few arguments to function call, expected 5, have 3 dmScript::JsonToLua(L, json, strlen(json)); #25

Closed robertnicjoo closed 1 year ago

robertnicjoo commented 1 year ago

This noon I built my app with no issue and tonight i cannot build my app regarding to this error

Screen Shot 2022-11-03 at 01 55 47

I was using master branch when this error occurred, then I came and saw new release available here with exact error title (however my happiness didn't last long) cause same error happened with this new release.

Here is the code that I'm trying to compile.

-- ads
local function update_ui(self)
    if self.ad_type == admob.MSG_INTERSTITIAL then
        admob.is_interstitial_loaded()
    elseif self.ad_type == admob.MSG_REWARDED then
        admob.is_rewarded_loaded()
    elseif self.ad_type == admob.MSG_BANNER then
        admob.is_banner_loaded()
    end
end

local function admob_callback(self, message_id, message)
    if message_id == admob.MSG_INITIALIZATION then
        self.initialized = true
    end
    if self.ad_type == admob.MSG_INTERSTITIAL then
        print("admob.load_interstitial()")
        admob.load_interstitial(self.interstitial_ad_unit)
        admob.show_interstitial()
    elseif self.ad_type == admob.MSG_REWARDED then
        print("admob.load_rewarded()")
        admob.load_rewarded(self.rewardedvideo_ad_unit)
        admob.show_rewarded()
        reload_banner()
    elseif self.ad_type == admob.MSG_BANNER then
        print("admob.load_banner()")
        admob.load_banner(self.banner_ad_unit)
        print("admob.show_banner("..admob.POS_BOTTOM_CENTER..")")
        admob.show_banner(admob.POS_BOTTOM_CENTER)
    end
    update_ui(self)
end

local function reload_banner()
    self.ad_type = admob.MSG_BANNER
    admob.set_callback(admob_callback)
end

local function get2xlife()
    ad_type = admob.MSG_REWARDED
    admob.set_callback(admob_callback)
end
-- ads

function init(self)
    msg.post(".", "acquire_input_focus")
    msg.post("@render:", "use_fixed_fit_projection")

    -- ads
    local engine_info = sys.get_engine_info()
    self.is_debug = engine_info.is_debug

    if self.is_debug then
        if sys.get_sys_info().system_name == 'iPhone OS' then
            self.banner_ad_unit = "ca-app-pub-3940256099942544/2934735716"
            self.interstitial_ad_unit = "ca-app-pub-3940256099942544/4411468910"
            self.rewardedvideo_ad_unit = "ca-app-pub-3940256099942544/1712485313"
        else --Android
            self.banner_ad_unit = "ca-app-pub-3940256099942544/6300978111"
            self.interstitial_ad_unit = "ca-app-pub-3940256099942544/1033173712"
            self.rewardedvideo_ad_unit = "ca-app-pub-3940256099942544/5224354917"
        end
    else
        if sys.get_sys_info().system_name == 'iPhone OS' then
            self.banner_ad_unit = "my_real_id"
            self.interstitial_ad_unit = "my_real_id"
            self.rewardedvideo_ad_unit = "my_real_id"
        else --Android
            self.banner_ad_unit = "my_real_id"
            self.interstitial_ad_unit = "my_real_id"
            self.rewardedvideo_ad_unit = "my_real_id"
        end
    end

    if admob then
        admob.set_callback(admob_callback)
        admob.set_privacy_settings(true)
        self.ad_type = admob.MSG_BANNER
        admob.initialize()
    end
    -- ads
end

function on_input(self, action_id, action)
    if (action_id == hash("touch") and action.released  == true) then
        local select1 = gui.get_node("playbyreward")
        if gui.pick_node(select1, action.x, action.y) then
            get2xlife()
        end
    end
end

Any suggestion?

AGulev commented 1 year ago

What is your Defold version?

AGulev commented 1 year ago

I see, pls avoid using link to the master branch, but the link to the needed release you can find here: https://github.com/defold/extension-admob/releases

if you use Defold 1.3.7, you need this vesrion of the extension: https://github.com/defold/extension-admob/archive/refs/tags/2.2.0.zip

robertnicjoo commented 1 year ago

I see, pls avoid using link to the master branch, but the link to the needed release you can find here: https://github.com/defold/extension-admob/releases

if you use Defold 1.3.7, you need this vesrion of the extension: https://github.com/defold/extension-admob/archive/refs/tags/2.2.0.zip

I try with 2.2.0 now i was trying 3.0.0 (latest release)