Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
Windows RT export with Ads - how?... — Gideros Forum

Windows RT export with Ads - how?...

MobAmuseMobAmuse Member
edited May 2017 in General questions
I'm going to start looking at Windows RT export soon with Ads.

I've only done Paid Windows RT apps exported via Gideros in the past and sold them on the store with some success.

Is there a procedure to follow regards using Ads on this platform? as looking at the Ads plugin on export, I have no idea what to select as compared to Android for example to do the same thing.

I looked at the Microsoft dev panel regards Ads and setup a Test banner ad which I want to show in app. It has an ID but I don't know where to put it in the Gideros code or Ads Plugin or even how to call it.

Thanks.

Comments

  • Actually I think the documentation needs updating, as it's great to have all these extra features constantly being added but no real way to know how to use them if it's a new thing perhaps.

    Likes: pie

    +1 -1 (+1 / -0 )Share on Facebook
  • hgy29hgy29 Maintainer
    Hi @MobAmuse,

    You can initialize WinRT ads with:
    ads=Ads.new("pubcenter")
    ads:setKey("your-appplication-id") -- MS ad center application id
    then use your ad unit id (as defined in your microsoft account) as the ad type (first arg of load/show/etc methods).

    Likes: pie, MobAmuse

    +1 -1 (+2 / -0 )Share on Facebook
  • Cheers thanks I will try this later this week and see how I get on with it.
  • john26john26 Maintainer
    @hgy29, can you tell us how to export a project so it contains the pubcenter plugin? I think you need to click the "select plugins" button on export, right? Do any files need to be manually copied?
  • hgy29hgy29 Maintainer
    edited May 2017
    Nothing needs to be copied (if I did it correctly). Just tick ads plugin in plugin selection pane and exporter will set it up for you.
    You will need to install Microsoft ads sdk from visual studio though...

    Likes: MobAmuse

    +1 -1 (+1 / -0 )Share on Facebook
  • MobAmuseMobAmuse Member
    edited May 2017
    Even with Microsoft Ads SDK stuff I get a build error in VS 2017.

    So far for testing I have in Lua code simply set require ads and ticked Ads plugin on export but don't actually call any ads just yet until I get the basic build process working below (see pic).
    Build1.png
    3000 x 1635 - 212K
  • Seems like I may be missing a reference to the installed SDK?
  • hgy29hgy29 Maintainer
    I think you are not installing the right extension. See attached pic for the correct one.
    WinRTAds.png
    1913 x 1075 - 171K

    Likes: MobAmuse

    +1 -1 (+1 / -0 )Share on Facebook
  • Seems so but can't find it in the extension manager.

    I can find 'Microsoft Advertising SDK' which downloads and installs when I click on it but that's it, it does not seem it actually install in reality.

    I am probably doing something very wrong :)
  • MobAmuseMobAmuse Member
    edited May 2017
    Just in case anybody else attempts this. Make sure you build with VS2015 and not VS2017 else you won't get anywhere with the needed ad sdk extensions install.
  • OK I got further once I could build with ads :)

    Could you possibly be more specific perhaps regards... 'then use your ad unit id (as defined in your microsoft account) as the ad type (first arg of load/show/etc methods).'

    I have in Lua code and export as WinRT with Ads Plugin ticked...

    require "ads"
    pubcenter=Ads.new("pubcenter")
    pubcenter:setKey("AppIDRemoved")

    pubcenter:LoadAd("AdIDRemoved") ...on it's own runs thru OK tho it seems.

    Once my code running on real device hits...

    pubcenter:showAd("AdIDRemoved")

    ...it throws an exception and crashes.

    Without pubcenter:showAd("AdIDRemoved") the code runs as normal.
  • Do I need to pass more args or something perhaps?
  • hgy29hgy29 Maintainer
    Hmm, just looked at the code and you need to pass a format as first arg of loadAd or showAd, unit id going in second place.

    Can you try:
    pubcenter:showAd("250x250","AdUnitId") ?

    Recognized formats are listed here: https://github.com/gideros/gideros/blob/master/plugins/ads/source/WinRT/Ads/frameworks/AdsPubcenter.cpp#L46, although I have no clue as where does this list come from...

    Likes: MobAmuse

    +1 -1 (+1 / -0 )Share on Facebook
  • john26john26 Maintainer
    edited May 2017
    Also I remember it crashes if I try to run via Visual Studio but if I run the app independently it works fine. So instead of just using Start in VS use "Run without debugging". Or just reboot your app directly from the phone/PC without using VS (VS will have installed the app on the device). No idea why.

    Here's a complete test example (main.lua) I tried and I get the attached screenshot
    require "ads"
     
    ads = Ads.new("pubcenter")
     
    ads:enableTesting()
     
    ads:addEventListener(Event.AD_DISPLAYED, function()
        print("ads AD_DISPLAYED")
     
    end)
     
    ads:addEventListener(Event.AD_RECEIVED, function()
        print("ads AD_RECEIVED")
    end)
     
    ads:addEventListener(Event.AD_FAILED, function(e)
        print("ads AD_FAILED", e.error)
    end)
     
    ads:addEventListener(Event.AD_ACTION_BEGIN, function()
        print("ads AD_ACTION_BEGIN")
    end)
     
    ads:addEventListener(Event.AD_ACTION_END, function()
        print("ads AD_ACTION_END")
    end)
     
    ads:addEventListener(Event.AD_DISMISSED, function()
        print("ads AD_DISMISSED")
    end)
     
    ads:addEventListener(Event.AD_ERROR, function(e)
        print("ads AD_ERROR", e.error)
    end)
     
    --[[
    ads:addEventListener(Event.AD_REWARDED, function(e)
        print("ads AD_REWARDED",e.amount)
    end)]]
     
     
    local function onVideo(btn, event)
        if btn:hitTestPoint(event.x, event.y)then
            ads:showAd("interstitial")
            ads:setPosition(10,300)
        end
    end
    local function onV4VC(btn, event)
        print(event.x,event.y)
        if btn:hitTestPoint(event.x, event.y) then
            ads:showAd("160x600")
        end
    end
    video = TextField.new(nil, "VIDEO")
    video:addEventListener(Event.MOUSE_DOWN, onVideo, video)
    video:setScale(5, 5)
    video:setPosition(10, 200)
    stage:addChild(video)
    v4vc = TextField.new(nil, "V4VC")
    v4vc:addEventListener(Event.MOUSE_DOWN, onV4VC, v4vc)
     
    v4vc:setScale(5, 5)
    v4vc:setPosition(100, 100)
    stage:addChild(v4vc)
    When I click on VIDEO I get the black square [Note: this would be a test advert if I was registered with Microsoft!]

    If I run the app without it being connected to VS it seems to work. I again get the black square if I press VIDEO and a tall black rectangle if I press V4VC

    Then after a moment it says FreeWheel etc Ad Test00:00:15 in the square (which turns white)
    wp_ss_20170326_0003.png
    720 x 1280 - 25K

    Likes: MobAmuse

    +1 -1 (+1 / -0 )Share on Facebook
  • MobAmuseMobAmuse Member
    edited May 2017
    Hi both,

    I tried both methods above but as soon as the code hits showAd(...any args method...) it throws this from real device in VS2015...

    Exception thrown at 0x6B8E16FB (vccorlib120_app.dll) in giderosgame.WindowsPhone.exe: 0xC0000005: Access violation reading location 0x0000006C.

    ...even running the app as standalone on real device just crashes on showAd(...any args method...)

    I've tried ads test mode and real ads mode but no go so far.
  • MobAmuseMobAmuse Member
    edited May 2017
    Also throws...

    Exception thrown at 0x0F7E21C7 (vccorlib120_app.dll) in giderosgame.Windows.exe: 0xC0000005: Access violation reading location 0x0000006C.

    ...via VS2015 emulator on showAd(...)
  • hgy29hgy29 Maintainer
    Can you provide a backtrace by any chance ?
  • All I can get is the call stack info at the bottom right of the screen in VS 2015...
    CallStack.png
    3000 x 1817 - 343K
  • john26john26 Maintainer
  • hgy29hgy29 Maintainer
    Not sure this is what happens, but some variables are not explicitly initialized at lines 30 and 31 of adspubcenter.cpp. Can you add at least 'ad = nullptr;' at line 30 ?
    it seems that showad is trying to access something that hasn't been initialized properly.
  • @john26 I did :)

    @hgy29 I will try that later and report back as stuck updating iOS apps at the moment.
  • MobAmuseMobAmuse Member
    edited May 2017
    OK I am fresh back from updating a virtual pile of iOS apps :)

    Even more odd if I add... ad = nullptr; ...to line 30 you can now see VS2015 throw 46 new build errors? If I take the line out it's builds OK (see screenshot attached) ...What!?

    I am using this test code based on john26's example but it still crashes (without that line 30 above of course)...
    require "ads"
    ads = Ads.new("pubcenter")
    ads:enableTesting()
     
    ads:addEventListener(Event.AD_DISPLAYED, function()
        print("ads AD_DISPLAYED") 
    end)
     
    ads:addEventListener(Event.AD_RECEIVED, function()
        print("ads AD_RECEIVED")
    end)
     
    ads:addEventListener(Event.AD_FAILED, function(e)
        print("ads AD_FAILED", e.error)
    end)
     
    ads:addEventListener(Event.AD_ACTION_BEGIN, function()
        print("ads AD_ACTION_BEGIN")
    end)
     
    ads:addEventListener(Event.AD_ACTION_END, function()
        print("ads AD_ACTION_END")
    end)
     
    ads:addEventListener(Event.AD_DISMISSED, function()
        print("ads AD_DISMISSED")
    end)
     
    ads:addEventListener(Event.AD_ERROR, function(e)
        print("ads AD_ERROR", e.error)
    end)
     
    text=TextField.new(nil, "TESTING 1 2 3")
    text:setScale(5,5)
    text:setPosition(16,16)
    stage:addChild(text)
     
    ads:setPosition(64,64)
    ads:showAd("interstitial")
    I think for now I am going to be stuck with more paid apps on the Windows App Store until somebody else can get it working perhaps.

    For now I have to move on though as more work awaits me elsewhere.
    Doomed.png
    1370 x 1752 - 204K
  • hgy29hgy29 Maintainer
    Sorry I probably wasn't precise enough: the original line 'AdControl^ ad;' must be changed into 'AdControl ^ad=nullptr;'.

    Likes: MobAmuse

    +1 -1 (+1 / -0 )Share on Facebook
  • Sorry yes I take everything anybody tells me literally usually :)

    No it still crashes exactly the same as before at showAd after rebuilding.
  • This is the line that appears to make it crash in showAd routine...

    gdr_getRootView()->Children->Append(ad);

    ...If I comment it out the code runs but with no ad showing of course.
  • hgy29hgy29 Maintainer
    All right, I found what happens: gdr_getRootView() can't be called from within gideros initialization routine, otherwise it returns invalid value. I will fix this for next build but meanwhile you can avoid the issue by delaying the 'showAd' by one frame (or more).

    Likes: MobAmuse

    +1 -1 (+1 / -0 )Share on Facebook
  • Yay! :) No worries I will wait until next release.

    Thanks.
Sign In or Register to comment.