Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Applovin ads do not load/show rewarded videos with newer public releases and builds
Started by zsolt_huszar Sep 28 2017 01:49 PM

5 replies to this topic
applovin ads

Best Answer zsolt_huszar , 20 November 2017 - 01:32 AM

Dear Brent, Dear Everyone,

 

The problem has been solved after many attempts based on ADB LOGCAT info, and mostly due to precious help from the Corona AppLovin Support team!

 

I would like to share the findings with you too:

 

- First, it turned out that the key problem was not the usage of global variables (luckily), but the setup of the AppLovin ads at Corona. The Corona AppLovin team had to update the parameters to match the ones set in my AppLovin dashboard.

It was unfortunately misleading that my earlier app version (built on an earlier AppLovin plugin version) worked correctly, which hinted to me that the AD setup was OK.

 

- Secondly, there was a "silly" and hidden error due to my debugging trials. The ADLISTENER did not work despite the corrected AD setup.

I placed earlier some print commands inside the ADLISTENER to see as many pieces of info as possible during running, such as:

 

local function adListener( event )

  print("RESPONSE: "..event.response)
  print("IS ERROR: "..event.isError)
  print("NAME : "..event.name)
  print("PHASE: "..event.phase)
  print("provider: "..event.provider)
  print("data: "..event.data)
  print("type: "..event.type)

  ...

 

The Corona team helped me find the reason why the ADLISTENER did not work due to the commands above:

"There is LuaRuntimeException on print("RESPONSE: "..event.response) line because of concatenating event.respone which has nil value."

 

And I could not see this error message in ADB LOGCAT lines filtered to "AppLovin" and "Corona" since the error was generated by JNILua.

So the above print lines were deleted and everything has been working fine now with the updated AD setup.

 

I hope that it could help others too in finding strange, hidden errors.

Thank you once again for the Forum and the Corona Team to solve the problem!

 

With best regards,

Zsolt Huszár

[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

zsolt_huszar

[GLOBAL: userInfoPane.html]
zsolt_huszar
  • Observer

  • 6 posts
  • Corona SDK

Hello Everyone,

 

I would need to ask for your help and advice.

I successfully built Applovin rewarded video ads into my app using Public Release 2016.2906.

With the same code, however, Applovin videos do not load/show using Public Release 2017.3068 and daily build 2017.3145.

There is not any error, simply the ads do not start. It seems to me like there is some problem during initialization.

 

I had checked forum entries and documentations, and made the following modifications in the earlier code (that worked well with 2016.2906):

 

1) "plugin.google.play.services" was removed from build.settings

The plugin part looks like this now:

 

    plugins =
    {
        ["plugin.applovin"] =
        {
            publisherId = "com.coronalabs",
            supportedPlatforms = { android=true }
        },
    },

 

2) In Applovin function calls the TRUE parameter was changed to the string "rewardedVideo" in every place.

The listener function looks like this (button2 is used to start a rewarded video if it has been loaded):

 

 
local function adListener( event )
 
    -----------------INIT
    --------------------------
    if ( event.phase == "init" ) then  -- Successful initialization
        print( event.isError )
        outputText.text = "message: INITIALIZED "..event.isError
        -- Load an AppLovin ad
       if applovin.isLoaded( "rewardedVideo" ) == false then 
             applovin.load("rewardedVideo")
       end
 
    -----------------LOADED
    --------------------------
    elseif ( event.phase == "loaded" ) then  -- The ad was successfully loaded
        print( event.type )
        outputText.text = "message: LOADED "..event.type
        button2.alpha = 1
        button2:setEnabled(true) 
 
    -----------------REWARD
    --------------------------
    elseif ( event.phase == "validationSucceeded" ) then   -- Indicates that the user viewed the ad and that their reward was approved by the AppLovin server.
        print( event.type )
        audio.play(coinsReceivedSound)
        outputText.text = "REWARD!!!          validationSucceeded "..event.type
        global_SilverCoins = global_SilverCoins + event.data.amount
        silverCoinBlock.refreshCoinValues()
        goldCoinBlock.refreshCoinValues() 
 
        -- Load an AppLovin ad
        if applovin.isLoaded( "rewardedVideo" ) == false then 
               applovin.load("rewardedVideo")
        end
 
 
    -----------------EXCEED QUOTA
    --------------------------
    elseif ( event.phase == "validationExceededQuota" ) then  -- Indicates that the AppLovin server was contacted, but the user has already received the maximum amount of rewards allowed in a given day.
        print( event.type )
        outputText.text = "message: validationExceededQuota "..event.type
 
    -----------------FAILED
    --------------------------
    elseif ( event.phase == "failed" ) then  -- The ad failed to load
        print( event.type )
        outputText.text = "FAILED ".."  "..event.type.."  "..event.isError.."  "..event.response
 
        -- Load an AppLovin ad
        if applovin.isLoaded( "rewardedVideo" ) == false then 
               applovin.load("rewardedVideo")
        end
 
    -----------------DISPLAYED
    --------------------------
    elseif ( event.phase == "displayed" ) then  -- Indicates that a graphical interstitial ad (non-video) was displayed.
        print( event.type )
        outputText.text = "message: DISPLAYED"..event.type
 
    -----------------PLAYBACK BEGAN
    --------------------------
    elseif ( event.phase == "playbackBegan" ) then  -- Indicates that a video interstitial ad was displayed.
        print( event.type )
        outputText.text = "message: PLAYBACK BEGAN "..event.type
 
    -----------------HIDDEN
    --------------------------
    elseif ( event.phase == "hidden") then  -- Indicates that a graphical interstitial ad (non-video) was closed/hidden.
        print( event.type )
        outputText.text = "message: HIDDEN "..event.type        
 
    -----------------PLAYBACK ENDED
    --------------------------
    elseif ( event.phase == "playbackEnded" ) then  -- Indicates that a video interstitial ad was closed/hidden.
        print( event.type )
        outputText.text = "message: PLAYBACK ENDED "..event.type        
 
        -- Load an AppLovin ad
        if applovin.isLoaded( "rewardedVideo" ) == false then 
               applovin.load("rewardedVideo")
        end
 
 
    -----------------CLICKED
    --------------------------
    elseif ( event.phase == "clicked" ) then  -- Indicates that an ad was clicked/tapped.
        print( event.type )
        outputText.text = "message: CLICKED "..event.type        
 
 
    -----------------DECLINED TO VIEW 
    --------------------------
    elseif ( event.phase == "declinedToView" ) then  -- Indicates that the user chose “no” when prompted to view the ad.
        print( event.type )
        outputText.text = "message: declinedToView "..event.type        
 
        -- Load an AppLovin ad
        if applovin.isLoaded( "rewardedVideo" ) == false then 
               applovin.load("rewardedVideo")
        end
    end
 
end

 
 
3) I tried to move the adListener and all the Applovin INIT calls to main.lua.
Originally (with 2016.2906) everything was placed in a separate LUA file of a dedicated Composer Scene handling rewarded videos, and INIT was called during its SCENE CREATE:
 

-- Initialize the AppLovin plugin

applovin.init( adListener, { sdkKey=mySDKKey } )


 
 

Unfortunately, neither of the above points did the trick.

Nevertheless, I was also wondering about the following at point 3):

 

- Does it make any sense to change the adListener to be global instead of local? Does it make any change during Applovin INIT?

- If the adListener defined in main.lua is local, will it work during my separate rewarded video's Composer Scene phase?

- Is it a must to call APPLOVIN INIT in main.lua?

- What happens if we require applovin as:

 

applovin = require( "plugin.applovin" )
 
instead of:
 
local applovin = require( "plugin.applovin" )

 

- Does it "overwrite" the Applovin INIT (and the adListener) of main.lua if I again require Applovin in my separate rewarded video Composer Scene?

- How could I refer from main.lua to the video play button of the separate Composer Scene (button2) in the adListener?

 

I gratefully look forward to any tips, hints, help or advice.

Thank you in advance! 

 
With best regards,
Zsolt


[TOPIC: post.html]
#2

bjsorrentino

[GLOBAL: userInfoPane.html]
bjsorrentino
  • Veteran

  • 8,506 posts
  • Corona SDK

Hi @Zsolt,

I would suggest you do not make anything global. It almost always causes problems.

 

Better to just init() AppLovin in main.lua, and also keep the listener function there.

 

It appears that you've based some of your code on the Corona sample, which is fine. Please check again that you have the most recent version of this, as it has been modified over time to adapt to AppLovin plugin changes:

https://github.com/coronalabs/plugins-sample-applovin

 

Brent



[TOPIC: post.html]
#3

zsolt_huszar

[GLOBAL: userInfoPane.html]
zsolt_huszar
  • Observer

  • 6 posts
  • Corona SDK

Dear Brent,

 

Many thanks for your quick response and support!

I will keep trying, and would let you know the results here.

 

I planned to read a related article (to see how to handle the cross module references, how to reach objects/variables of a Composer Scene from main.lua) at:

https://coronalabs.com/blog/2015/12/15/tutorial-implementing-cross-module-functions-and-events/

But it was removed.

 

Fortunately, I have found an archive of that at:

http://www.sdknews.com/cross-platform/corona/tutorial-implementing-cross-module-functions-and-events

 

Regarding global variables: I will surely take your advice in my next app!

However, as the app in question was built on using several global vars, I do hope I can fix that without major modifications, since the code is quite complex now (over 30 000 lines)...

 

Please, let me turn back to you in case I get stuck.

 

Many, many thanks and kind regards,

 

Zsolt



[TOPIC: post.html]
#4

zsolt_huszar

[GLOBAL: userInfoPane.html]
zsolt_huszar
  • Observer

  • 6 posts
  • Corona SDK

  Best Answer

Dear Brent, Dear Everyone,

 

The problem has been solved after many attempts based on ADB LOGCAT info, and mostly due to precious help from the Corona AppLovin Support team!

 

I would like to share the findings with you too:

 

- First, it turned out that the key problem was not the usage of global variables (luckily), but the setup of the AppLovin ads at Corona. The Corona AppLovin team had to update the parameters to match the ones set in my AppLovin dashboard.

It was unfortunately misleading that my earlier app version (built on an earlier AppLovin plugin version) worked correctly, which hinted to me that the AD setup was OK.

 

- Secondly, there was a "silly" and hidden error due to my debugging trials. The ADLISTENER did not work despite the corrected AD setup.

I placed earlier some print commands inside the ADLISTENER to see as many pieces of info as possible during running, such as:

 

local function adListener( event )

  print("RESPONSE: "..event.response)
  print("IS ERROR: "..event.isError)
  print("NAME : "..event.name)
  print("PHASE: "..event.phase)
  print("provider: "..event.provider)
  print("data: "..event.data)
  print("type: "..event.type)

  ...

 

The Corona team helped me find the reason why the ADLISTENER did not work due to the commands above:

"There is LuaRuntimeException on print("RESPONSE: "..event.response) line because of concatenating event.respone which has nil value."

 

And I could not see this error message in ADB LOGCAT lines filtered to "AppLovin" and "Corona" since the error was generated by JNILua.

So the above print lines were deleted and everything has been working fine now with the updated AD setup.

 

I hope that it could help others too in finding strange, hidden errors.

Thank you once again for the Forum and the Corona Team to solve the problem!

 

With best regards,

Zsolt Huszár



[TOPIC: post.html]
#5

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 24,308 posts
  • Corona Staff

Just as an FYI, even though it will insert a tab and add some white space, it's always safer to do:

print("RESPONSE", event.response)   -- if event.response is nil, it will just print "RESPONSE"

Note the "comma" instead of the ".." concatenation operator. If the value is nil, it will print nothing, or nil, if there are other things to print on the line, such as:


print("RESPONSE", event.response, ".") -- if event.response is nil, it will print "RESPONSE   nil  .

You will never get the nil concatenation crashes if you do that.

 

Rob



[TOPIC: post.html]
#6

zsolt_huszar

[GLOBAL: userInfoPane.html]
zsolt_huszar
  • Observer

  • 6 posts
  • Corona SDK

Dear Rob,

 

Thank you very much for your useful advice!

I will surely do this way in the future...

 

Many thanks once again to the Corona specialists!

 

Kind regards,

Zsolt




[topic_controls]
 
[/topic_controls]