Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

appodeal.canShow() crashes the app
Started by philipp3 Nov 04 2018 04:05 AM

9 replies to this topic
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

philipp3

[GLOBAL: userInfoPane.html]
philipp3
  • Enthusiast

  • 63 posts
  • Corona SDK

Hello,

 

I would like to find out if the user is in flight mode, and thought that would possibly work with appodeal.canShow("xyz").

In the docs, it says that the call should work with the modular beta plugins, which I am using. Daily build 3393 for Android.

But whenever I call the line, the app crashes. I hoped it would at least return nil. appodeal.isLoaded() works fine. These are the lines in the code:

print ("ABCD")
print (appodeal.canShow("banner"))
 
.. and in the console, I get:
 
11-04 12:56:37.863 28039 28054 I Corona  : ABCD

11-04 12:56:37.865 28039 28054 I Corona  : ERROR: Runtime error

11-04 12:56:37.865 28039 28054 I Corona  : java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object android.content.Context.getSystemService(java.lang.String)' on a null object reference



[TOPIC: post.html]
#2

agramonte

[GLOBAL: userInfoPane.html]
agramonte
  • Contributor

  • 824 posts
  • Corona SDK

what version of appodeal and corona are you using? I remember this being an older issue.


  • roaminggamer likes this

[TOPIC: post.html]
#3

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,286 posts
  • Corona SDK

have you confirmed the initialization worked before calling that function?



[TOPIC: post.html]
#4

philipp3

[GLOBAL: userInfoPane.html]
philipp3
  • Enthusiast

  • 63 posts
  • Corona SDK

what version of appodeal and corona are you using? I remember this being an older issue.

 

I use Corona 3393, and the Appodeal version is built in accordingly I guess?

 

have you confirmed the initialization worked before calling that function?

 

Yes, one line before, I call appodeal.isLoaded(), that works fine.



[TOPIC: post.html]
#5

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 24,860 posts
  • Corona Staff

Can you provide a little more insight on your implementation? That is can you show us your initialization code, callback listener and what order/when you're calling .isLoaded()?

 

Rob



[TOPIC: post.html]
#6

agramonte

[GLOBAL: userInfoPane.html]
agramonte
  • Contributor

  • 824 posts
  • Corona SDK

I just tested:

  1. Android Pie.
  2. Corona Version 3426.

And at least for me, it worked as expected.

 

Also isLoaded is not the init that roaminggamer was talking about.

 

You first init. For example something like this:

appodeal.init( appodealListerner, { appKey=appodealId, disableWriteExternalPermissionCheck=true, testMode=false, hasUserConsent=false } )

And then you wait for the response back:

local appodealListerner = function( event )
	
	if event.phase == "init" then  -- Successful initialization
	 -- do stuff with banner
	elseif event.data ~= nil and event.type == "rewardedVideo" and event.data.name == "reward" and event.phase == "playbackEnded" then
		-- do other stuff
	elseif event.type == "rewardedVideo" and event.phase == "closed" then
		-- do other stuff
	end

end


[TOPIC: post.html]
#7

philipp3

[GLOBAL: userInfoPane.html]
philipp3
  • Enthusiast

  • 63 posts
  • Corona SDK

 

I just tested:

  1. Android Pie.
  2. Corona Version 3426.

And at least for me, it worked as expected.

 

Also isLoaded is not the init that roaminggamer was talking about.

 

You first init. For example something like this:

appodeal.init( appodealListerner, { appKey=appodealId, disableWriteExternalPermissionCheck=true, testMode=false, hasUserConsent=false } )

And then you wait for the response back:

local appodealListerner = function( event )
	
	if event.phase == "init" then  -- Successful initialization
	 -- do stuff with banner
	elseif event.data ~= nil and event.type == "rewardedVideo" and event.data.name == "reward" and event.phase == "playbackEnded" then
		-- do other stuff
	elseif event.type == "rewardedVideo" and event.phase == "closed" then
		-- do other stuff
	end

end

 

I init a bit before, I just wanted to mention that a similar function works fine. I don’t have the chance to test it with 3426 at the moment, but I will later. It’s not critical, I was just curious, but it’s good to know that it works for you. Below is the code that I am using.

 

 


Can you provide a little more insight on your implementation? That is can you show us your initialization code, callback listener and what order/when you're calling .isLoaded()?

 

Rob

 

 

 

Sure, this is the code part:

local function appodealListener(e)
    if e.phase == "init" then
	print ("hello appodeal")
    elseif e.phase == "failed" then
	print("no appodeal", e.type, e.isError, e.response)
    end
end


appodeal.init(appodealListener, {appKey = "...", hasUserConsent = false, locationTracking = false, supportedAdTypes = {"..."}, bannerAnimation = true})




--- later in the game, the first time with 3000ms delay:

function showVideo()
    local isAppodealLoaded = appodeal.isLoaded("rewardedVideo")
    local canAppodealShow = appodeal.canShow("rewardedVideo") -- app crashes here
    if (isAppodealLoaded and canAppodealShow) then
	appodeal.show("rewardedVideo")
	return false
    else
	appodeal.load("rewardedVideo")
    end
end




[TOPIC: post.html]
#8

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 24,860 posts
  • Corona Staff

Please take time to read this:

 

http://docs.coronalabs.com/tutorial/basics/ads/index.html

 

Rob



[TOPIC: post.html]
#9

agramonte

[GLOBAL: userInfoPane.html]
agramonte
  • Contributor

  • 824 posts
  • Corona SDK

1. Test using the beta. At one point canShow was not available in the non-beta version. I also don't believe it is available in the Amazon version.

2. My code is similar-ish. I would put a boolean in the init to make sure that appodeal actually initializes.

3. Then I would check the boolean before making any calls.

local appodealReady = false

local function appodealListener(e)
    if e.phase == "init" then
	print ("hello appodeal")
        appodealReady = true
    elseif e.phase == "failed" then
	print("no appodeal", e.type, e.isError, e.response)
    end
end


[TOPIC: post.html]
#10

philipp3

[GLOBAL: userInfoPane.html]
philipp3
  • Enthusiast

  • 63 posts
  • Corona SDK

 

1. Test using the beta. At one point canShow was not available in the non-beta version. I also don't believe it is available in the Amazon version.

2. My code is similar-ish. I would put a boolean in the init to make sure that appodeal actually initializes.

3. Then I would check the boolean before making any calls.

local appodealReady = false

local function appodealListener(e)
    if e.phase == "init" then
	print ("hello appodeal")
        appodealReady = true
    elseif e.phase == "failed" then
	print("no appodeal", e.type, e.isError, e.response)
    end
end

 

My code works fine with Build 3426. Really seems to be a build-number related issue.

 

Thanks for your help.




[topic_controls]
[/topic_controls]