Ads sample project not showing ads

Hi, I am trying to use InMobi ads, I created an account and have account ID, I used the sample code in the guides to see how it works this one:

(to make sure im not making any mistakes) I used my account ID and built the app to android apk -> copied it and installed on a device, now the app launchs and there are 2 buttons you can see in the picture here:

once I click one of em , it shows a loading spinner for a second and thats it… nothing appears, tried on testMode on and off, not difference

Someone ? wheres rob… :frowning:
and remove the 50 character limit that’s stopping people from helping this already near death community , I really wanna get this over with …

  1. Where is Rob: So long, and thanks for all the "Fishies" - A personal note from Rob

  2. What does your log say. i.e. Use logcat and see what is happening under the hood.

  3. The community is not near death, so please don’t ask for help then lambaste the forums/community/sdk all in one fell swoop. I think folks are having a little trouble adjusting to the new forums, but I still see regular queries and responses. Also, you asked your question on a Sunday so… I’m guessing nobody was reading or those who were didn’t have time to engage.

  4. As far as 50 character limit, that seems like a good idea to me. Keeps out junk posts.

PS - For future readers with a similar issue if you’re using an iOS device, look at the log under xCode. In this case, the user is on Android can get more details by looking at the log with logcat.

2 Likes

additional details for device debugging https://docs.coronalabs.com/guide/basics/debugging/index.html#device-debugging-android

I cant log, first the device is unrecognized , second when giving the cat commend is says waiting for devices and that’s it, overall it wont debug… so I was trying to solve it without debugging because solving the debug will take time aswell…

Sorry to break it to you, but your best option is to work out the kinks in why you can’t debug your android device. Otherwise you’re just running blind. Since you want to make money (via ads), you’ll need to invest the time. Alternately, you can skip the ads (I suggest this).

Note: You may not have enabled developer mode and/or may not have enabled USB debugging.

Google for: USB debugging Android ##.##
, where ##.## is the exact Android version of your device which you can find on your phone by digging into the settings.

2 Likes

ok so I debugged and here is the log

--------- beginning of main
--------- beginning of system
V/Corona (11481): > Class.forName: network.LuaLoader
V/Corona (11481): < Class.forName: network.LuaLoader
V/Corona (11481): Loading via reflection: network.LuaLoader
I/Corona (11481): Platform: GT-I9500 / ARM Neon / 5.0.1 / PowerVR SGX 544MP / OpenGL ES 2.0 build 1.10@2359475 / 2018.3326 / עברית | IL | iw_IL | iw
V/Corona (11481): > Class.forName: _Corona_Build_Number.LuaLoader
V/Corona (11481): > Class.forName: shared.google.play.services.base.LuaLoader
V/Corona (11481): < Class.forName: shared.google.play.services.base.LuaLoader
V/Corona (11481): Loading via reflection: shared.google.play.services.base.LuaLoader
V/Corona (11481): > Class.forName: _CoronaSetup.LuaLoader
V/Corona (11481): > Class.forName: CoronaProvider.licensing.google.LuaLoader
V/Corona (11481): < Class.forName: CoronaProvider.licensing.google.LuaLoader
V/Corona (11481): Loading via reflection: CoronaProvider.licensing.google.LuaLoader
V/Corona (11481): > Class.forName: plugin.inMobi.LuaLoader
V/Corona (11481): < Class.forName: plugin.inMobi.LuaLoader
V/Corona (11481): Loading via reflection: plugin.inMobi.LuaLoader
I/Corona (11481): plugin.inMobi: 1.1.9 (SDK: 7.1.1)
I/Corona (11481): InMobi event: initialization successful
I/Corona (11481): InMobi event: banner ad failed to load
I/Corona (11481): InMobi event: banner ad failed to load
I/Corona (11481): InMobi event: banner ad failed to load
I/Corona (11481): InMobi event: interstitial ad failed to load

I didn’t change anything in the code, and I used my ID as shown in my inmobi portal

you can see the full code here:

Summary
-- Abstract: InMobi
-- Version: 1.0
-- Sample code is MIT licensed; see https://www.coronalabs.com/links/code/license
---------------------------------------------------------------------------------------

display.setStatusBar( display.HiddenStatusBar )

------------------------------
-- RENDER THE SAMPLE CODE UI
------------------------------
local sampleUI = require( "sampleUI.sampleUI" )
sampleUI:newUI( { theme="darkgrey", title="InMobi", showBuildNum=true } )

------------------------------
-- CONFIGURE STAGE
------------------------------
display.getCurrentStage():insert( sampleUI.backGroup )
local mainGroup = display.newGroup()
display.getCurrentStage():insert( sampleUI.frontGroup )

----------------------
-- BEGIN SAMPLE CODE
----------------------

-- Require libraries/plugins
local widget = require( "widget" )
local inMobi = require( "plugin.inMobi" )

-- Set app font
local appFont = sampleUI.appFont

-- Preset the InMobi account ID (replace this with your own for testing/release)
-- This ID can be found within the InMobi developer portal: https://www.inmobi.com/portal/
local accountID = "aa6835788635*******************"

-- Preset InMobi placement IDs (replace these with your own)
local bannerPlacementID
local interstitialPlacementID
if ( system.getInfo("platformName") == "Android" ) then  -- Android
	bannerPlacementID = "157946397*****"
	interstitialPlacementID = "157682******"
elseif ( system.getInfo("platformName") == "iPhone OS" ) then  --iOS
	bannerPlacementID = "1579463********"
	interstitialPlacementID = "15768********"
end

-- Table of data for menu buttons
local menuButtons = {
	loadBanner = { label="Load Banner Ad", y=120 },
	showBanner = { label="Show Banner Ad", y=170 },
	hideBanner = { label="Hide Banner Ad", y=220 },
	loadInterstitial = { label="Load Interstitial Ad", y=285 },
	showInterstitial = { label="Show Interstitial Ad", y=335 }
}

-- Set local variables
local setupComplete = false

-- Create objects to visually prompt action
local bannerPrompt = display.newPolygon( mainGroup, 62, menuButtons["loadBanner"].y, { 0,-12, 12,0, 0,12 } )
bannerPrompt:setFillColor( 0.8 )
bannerPrompt.alpha = 0
local interstitialPrompt = display.newPolygon( mainGroup, 62, menuButtons["loadInterstitial"].y, { 0,-12, 12,0, 0,12 } )
interstitialPrompt:setFillColor( 0.8 )
interstitialPrompt.alpha = 0

-- Create spinner widget for indicating ad status
widget.setTheme( "widget_theme_android_holo_light" )
local spinner = widget.newSpinner( { x=display.contentCenterX, y=410, deltaAngle=10, incrementEvery=10 } )
mainGroup:insert( spinner )
spinner.alpha = 0


-- Function to manage spinner appearance/animation
local function manageSpinner( action )

	if ( action == "show" ) then
		spinner:start()
		transition.cancel( "spinner" )
		transition.to( spinner, { alpha=1, tag="spinner", time=((1-spinner.alpha)*320), transition=easing.outQuad } )
	elseif ( action == "hide" ) then
		transition.cancel( "spinner" )
		transition.to( spinner, { alpha=0, tag="spinner", time=((1-(1-spinner.alpha))*320), transition=easing.outQuad,
			onComplete=function() spinner:stop(); end } )
	end
end


-- Function to update button visibility/state
local function updateUI( params )

	-- Disable inactive buttons
	for i = 1,#params["disable"] do
		local ref = params["disable"][i]
		local button = menuButtons[ref]["object"]
		button:setEnabled( false )
		button.alpha = 0.3
	end

	-- Move/transition banner ad prompt
	if ( params.bannerPromptTo ) then
		transition.to( bannerPrompt, { y=menuButtons[params.bannerPromptTo].y, alpha=1, time=400, transition=easing.outQuad } )
	end

	-- Move/transition interstitial ad prompt
	if ( params.interstitialPromptTo ) then
		transition.to( interstitialPrompt, { y=menuButtons[params.interstitialPromptTo].y, alpha=1, time=400, transition=easing.outQuad } )
	end

	-- Enable new active buttons
	timer.performWithDelay( 400,
		function()
			for i = 1,#params["enable"] do
				local ref = params["enable"][i]
				local button = menuButtons[ref]["object"]
				button:setEnabled( true )
				button.alpha = 1
			end
		end
		)
end


-- Ad listener function
local function adListener( event )

	-- Exit function if user hasn't set up testing parameters
	if ( setupComplete == false ) then return end

	-- Successful initialization of the InMobi plugin
	if ( event.phase == "init" ) then
		print( "InMobi event: initialization successful" )
		-- Enable both buttons to load ads
		updateUI( { enable={ "loadBanner","loadInterstitial" }, disable={ "showBanner","hideBanner","showInterstitial" }, bannerPromptTo="loadBanner", interstitialPromptTo="loadInterstitial" } )

	-- An ad loaded successfully
	elseif ( event.phase == "loaded" ) then
		print( "InMobi event: " .. tostring(event.type) .. " ad loaded successfully" )
		-- Enable show button
		if ( event.type == "banner" ) then
			updateUI( { enable={ "showBanner" }, disable={ "loadBanner","hideBanner" }, bannerPromptTo="showBanner" } )
		elseif ( event.type == "interstitial" ) then
			updateUI( { enable={ "showInterstitial" }, disable={ "loadInterstitial" }, interstitialPromptTo="showInterstitial" } )
		end
		manageSpinner( "hide" )

	-- An interstitial ad was closed by the user
	elseif ( event.phase == "closed" ) then
		print( "InMobi event: " .. tostring(event.type) .. " ad closed by user" )
		-- Enable button to load another interstitial; disable button to show interstitial
		updateUI( { enable={ "loadInterstitial" }, disable={ "showInterstitial" }, interstitialPromptTo="loadInterstitial" } )

	-- The ad was clicked/tapped
	elseif ( event.phase == "clicked" ) then
		print( "InMobi event: " .. tostring(event.type) .. " ad clicked/tapped by user" )

	-- The ad failed to load
	elseif ( event.phase == "failed" ) then
		print( "InMobi event: " .. tostring(event.type) .. " ad failed to load" )
		-- Reset to load button
		if ( event.type == "banner" ) then
			updateUI( { enable={ "loadBanner" }, disable={ "showBanner","hideBanner" }, bannerPromptTo="loadBanner" } )
		elseif ( event.type == "interstitial" ) then
			updateUI( { enable={ "loadInterstitial" }, disable={ "showInterstitial" }, interstitialPromptTo="loadInterstitial" } )
		end
		manageSpinner( "hide" )
	end
end


-- Function to prompt/alert user for setup
local function checkSetup()

	if ( system.getInfo( "environment" ) ~= "device" ) then return end

	if ( tostring(accountID) ~= "aa6835788635*******************" ) then
		local alert = native.showAlert( "Important", 'Confirm that you have specified your InMobi account ID within "main.lua" on line 35. This ID can be found within the InMobi developer portal.', { "OK", "inmobi.com" },
			function( event )
				if ( event.action == "clicked" and event.index == 2 ) then
					system.openURL( "https://www.inmobi.com/portal/" )
				end
			end )

	elseif ( system.getInfo("platformName") == "Android" and ( tostring(bannerPlacementID) ~= "15794*********" or tostring(interstitialPlacementID) ~= "157682*******" ) ) then
		local alert = native.showAlert( "Important", 'Confirm that you have specified two unique InMobi ad placement IDs within "main.lua" on lines 41-42. These can be generated within the InMobi developer portal.', { "OK", "inmobi.com" },
			function( event )
				if ( event.action == "clicked" and event.index == 2 ) then
					system.openURL( "https://www.inmobi.com/portal/" )
				end
			end )

	elseif ( system.getInfo("platformName") == "iPhone OS" and ( tostring(bannerPlacementID) ~= "15794********" or tostring(interstitialPlacementID) ~= "15768*******" ) ) then
		local alert = native.showAlert( "Important", 'Confirm that you have specified two unique InMobi ad placement IDs within "main.lua" on lines 44-45. These can be generated within the InMobi developer portal.', { "OK", "inmobi.com" },
			function( event )
				if ( event.action == "clicked" and event.index == 2 ) then
					system.openURL( "https://www.inmobi.com/portal/" )
				end
			end )
	else
		setupComplete = true
	end
end


-- Button handler function
local function onButtonRelease( event )

	if ( event.target.id == "loadBanner" ) then
		inMobi.load( "banner", bannerPlacementID )
		manageSpinner( "show" )

	elseif ( event.target.id == "showBanner" ) then
		if ( inMobi.isLoaded( bannerPlacementID ) == true ) then
			updateUI( { enable={ "hideBanner" }, disable={ "loadBanner","showBanner" }, bannerPromptTo="hideBanner" } )
			inMobi.show( bannerPlacementID, { yAlign="bottom" } )
		end

	elseif ( event.target.id == "hideBanner" ) then
		updateUI( { enable={ "loadBanner" }, disable={ "showBanner","hideBanner" }, bannerPromptTo="loadBanner" } )
		inMobi.hide( bannerPlacementID )

	elseif ( event.target.id == "loadInterstitial" ) then
		inMobi.load( "interstitial", interstitialPlacementID )
		manageSpinner( "show" )

	elseif ( event.target.id == "showInterstitial" ) then
		if ( inMobi.isLoaded( interstitialPlacementID ) == true ) then
			inMobi.show( interstitialPlacementID )
		end
	end
	return true
end


-- Loop through table to display buttons
for k,v in pairs( menuButtons ) do

	local button = widget.newButton(
		{
			label = v.label,
			id = k,
			shape = "rectangle",
			width = 188,
			height = 32,
			font = appFont,
			fontSize = 16,
			fillColor = { default={ 0.12,0.32,0.52,1 }, over={ 0.132,0.352,0.572,1 } },
			labelColor = { default={ 1,1,1,1 }, over={ 1,1,1,1 } },
			onRelease = onButtonRelease
		})
	button.x = display.contentCenterX + 10
	button.y = v.y
	button:setEnabled( false )
	button.alpha = 0.3
	menuButtons[k]["object"] = button
	mainGroup:insert( button )
end


-- Initially alert user to set up device for testing
checkSetup()

-- Initialize the InMobi plugin
if ( setupComplete == true ) then
	inMobi.init( adListener, { accountId=accountID, logLevel="debug", testMode=true } )
end

also build.settings left untouched:

Summary
--
-- For more information on build.settings see here:
-- http://docs.coronalabs.com/guide/distribution/buildSettings/index.html
--

settings =
{
	orientation = {
		default = "portrait",
		supported = { "portrait", "portraitUpsideDown" }
	},

	iphone =
	{
		plist =
		{
			CFBundleIconFiles =
			{
				"Icon-40.png",
				"Icon-58.png",
				"Icon-76.png",
				"Icon-80.png",
				"Icon-87.png",
				"Icon-120.png",
				"Icon-152.png",
				"Icon-167.png",
				"Icon-180.png",
			},
			NSAppTransportSecurity = { NSAllowsArbitraryLoads=true },
		},
	},

	window =
	{
		titleText =
		{
			default = "InMobi",
		},
	},

	plugins =
	{
		["plugin.inMobi"] =
        {
            publisherId = "com.coronalabs"
        },
	},
}

I am not sure if the docs and/or example are wrong, but I’m 99% sure this part is incorrect:

inMobi.init( adListener, { accountId=accountID, logLevel="debug", testMode=true } )

Try this instead:

inMobi.init( adListener, { accountId=bannerPlacementID, logLevel="debug", testMode=true } )

It has been a long time since I did this, but I’m sure my old code uses a placementID as the accountID.

If this doesn’t work for you, just post back and i’ll try to dig out my own inMobi example(s).

If it does work, sorry I didn’t catch this sooner. :frowning:

changed , made sure I rebuild and installed the app again on the device… still the same error

I’ll dig into my ad code this weekend and see if I can get one of my inMobi examples working. Either way, I’ll ping you back this weekend.

@tal_nahum,

I’m trying to get an example working now, but running into an issue building with the inMobi plugin.

While I dig around, please check the version of the simulator you’re using and post it here.

Right now I’m using: 2020.3579

@tal_nahum

I gave this a try and can init, but am getting an ‘ad not served’ error.
… Corona : plugin.inMobi: 1.1.9 (SDK: 7.1.1)
… Corona : inMobi Listener Event @ function: 0x70bc8ae3d0
… Corona : isError: false; phase == “init”; response == “nil”
… Corona : Init phase completed!
… Corona : inMobi Listener Event @ function: 0x70bc8ae3d0
… Corona : isError: true; phase == “failed”; response == “NO_FILL - Ad request successful but no ad served.”
… Corona : inMobi is getting errors.
… Corona : placementId xxxxxxx
… Corona : type banner
… I Corona : isError true
… Corona : phase failed
… Corona : provider inMobi
… Corona : name adsRequest
… Corona : response NO_FILL - Ad request successful but no ad served.

You can check on this with your build by adding this code:
– Ad listener function
local function adListener( event )
for k,v in pairs(event) do
print( k, v )
end

This will print out verbose details for every event.

Hi again. I’m afraid I don’t have good news, but I want to summarize and clarify:

  1. My initial advice about the accountId was WRONG. Your initial code was correct.

  2. I have tried this with two different inMobi accounts and both produce the same “NOFILL…” error when I try to load a banner ad.

  3. I tried simply ‘showing’ and too and that failed with a ‘not loaded yet’ error.

At this point, I’m stymied. I can’t decide if there is an issue with inMobi, my account set up, or the plugin.

Tip: I also added my device under the devices list on my inMobi settings. That did not help either.

PS - It is worth noting, that my log says I’m using inMobi SDK: 7.1.1, while I believe the current version is 9.0.7.

I have to wonder if this version is simply not compatible with my test device which runs Android 10.

Yay, moments later I noticed a major issue.

I had my phone in ‘Airplane Mode’ + Forced WiFi ON This wasn’t good enough.

I had to turn off Airplane mode. I then changed to showing ‘interstial ads’ and Viola, it worked!

I still can’t show banner ads, but this is a step forward.

Here is the project I used: https://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2020/05/inMobiHelp.zip

You can edit main.lua and add your own IDs to test it and see if it works.

After that I leave it up to you to decide what to do.

Ok I haven’t used ur code yet, but I added that loop in the adlistener function, and heres the log

V/Corona (13851): > Class.forName: network.LuaLoader
V/Corona (13851): < Class.forName: network.LuaLoader
V/Corona (13851): Loading via reflection: network.LuaLoader
I/Corona (13851): Platform: GT-I9500 / ARM Neon / 5.0.1 / PowerVR SGX 544MP / OpenGL ES 2.0 build 1.10@2359475 / 2018.3326 / עברית | IL | iw_IL | iw
V/Corona (13851): > Class.forName: _Corona_Build_Number.LuaLoader
V/Corona (13851): > Class.forName: shared.google.play.services.base.LuaLoader
V/Corona (13851): < Class.forName: shared.google.play.services.base.LuaLoader
V/Corona (13851): Loading via reflection: shared.google.play.services.base.LuaLoader
V/Corona (13851): > Class.forName: _CoronaSetup.LuaLoader
V/Corona (13851): > Class.forName: CoronaProvider.licensing.google.LuaLoader
V/Corona (13851): < Class.forName: CoronaProvider.licensing.google.LuaLoader
V/Corona (13851): Loading via reflection: CoronaProvider.licensing.google.LuaLoader
V/Corona (13851): > Class.forName: plugin.inMobi.LuaLoader
V/Corona (13851): < Class.forName: plugin.inMobi.LuaLoader
V/Corona (13851): Loading via reflection: plugin.inMobi.LuaLoader
I/Corona (13851): plugin.inMobi: 1.1.9 (SDK: 7.1.1)
I/Corona (13851): phase init
I/Corona (13851): provider inMobi
I/Corona (13851): name adsRequest
I/Corona (13851): isError false
I/Corona (13851): InMobi event: initialization successful
I/Corona (13851): placementId 157946*******
I/Corona (13851): type banner
I/Corona (13851): name adsRequest
I/Corona (13851): phase failed
I/Corona (13851): provider inMobi
I/Corona (13851): isError true
I/Corona (13851): response REQUEST_INVALID - Please check the site status on InMobi dashboard or reach out to PartnerManager
I/Corona (13851): InMobi event: banner ad failed to load

So im gonna check afew more things, can you realize whats the problem source now ?
my simulator version says 2018.3326

Ur app shows the same error :

I/Corona (20915): plugin.inMobi: 1.1.9 (SDK: 7.1.1)
I/Corona (20915): inMobi Listener Event @ function: 0xae2ae0d0
I/Corona (20915): isError: false; phase == “init”; response == “nil”
I/Corona (20915): Init phase completed!
I/Corona (20915): inMobi Listener Event @ function: 0xae2ae0d0
I/Corona (20915): isError: true; phase == “failed”; response == “REQUEST_INVALID - Please check the site status on InMobi dashboard or reach out to PartnerManager”
I/Corona (20915): inMobi is getting errors.
I/Corona (20915): placementId 1576824*******
I/Corona (20915): type interstitial
I/Corona (20915): name adsRequest
I/Corona (20915): phase failed
I/Corona (20915): provider inMobi
I/Corona (20915): isError true
I/Corona (20915): response REQUEST_INVALID - Please check the site status on InMobi dashboard or reach out to PartnerManager

this is the ad on inmobi page, not much to see here

That simulator version is reallly old. I strong suggest updating.

However, before you do, be sure you still have the OLD installer around.

I don’t want you to get into a situation where you relied on some feature of that old version of Corona that isn’t working the same. i.e. If you have the old installer, you have a way back to the version you’re using now. I personally kept a cache of all installers for Windows and Mac as they got updated (going back to 2012). While I don’t have every release, I have most.

If you don’t have the installer and you find you absolutely need to roll back, I have 2018.3297 for Windows/OSX as well as 2018.3363 for Windows/OSX.

Still using such an old version is really not a good idea.

I will update, I highly doubt it will solve the problem, searching for this error I found that inmobi does not respond and the users ended up switching to other platform, I will keep you update

meanwhile if you can suggest a free services for ads that will be good, I tried appnext but their require to publish your app before starting to monetize

download the latest 2020, not working still
also I downloaded it from corona labs site, dunno whats with the open source and name change when public build is still the same
should I use solar 2d?

Answering both posts.

  1. I don’t think it will solve your problem either, but using a (very) old version is generally not a good idea, because:
  • it can have bugs that are not in the recent version(s)
  • it may be using old libraries which may cause you issues when you go to release the game
  • it isn’t the same as the version most people have. You want to reduce the number of differences between your setup and others’ setups when cross debugging. More factors equal more things to track down and consider.
  1. Suggestions for Ad sources. I’m probably not the best person for this kind of advice, but:
  • My first suggestion is not to monetize at all. i.e. Nobody likes ads and most games won’t make much money with them. That said, people rarely listen to my advice on this…
  • My second suggestion… would be any of these in my order of preference/experience: Vungle5, Applovin, Appodeal, Admob. Note: Admob would be at the top, but I think the plugin for it is still paid, so if you don’t have a license you may be out of luck.
  1. Huh? ‘Latest’ is not a version number… - You said you downloaded the latest 2020, but that isn’t enough info. When asking for help (and continuing a thread) it is always best to say exactly what version you have. For example, I am running Solar2D 2020.3595 as downloaded via the page linked at the top of this page ‘Latest Build’. Please remember to be precise and detailed when describing problems and your setup, otherwise folks have to guess what you mean.

  2. Same error? - Are you sure you’re getting the same error after updating? i.e. I am getting a NO FILL error for banners. You seem to be getting a ‘REQUEST_INVALID’ for all ad types? Is that still true?

  3. Did you add your test device ID to your inMobi devices test list (under settings)?

You can get this id, by:
A. Running logcat like this: adb logcat
i.e. Do not filter for just Corona messages.

B. Init inMobi in debug mode (you are already doing this).

C. Look at the log and find messages with this string --> [inMobi]
One of these will have a ‘device ID’. Grab it and add that ID to your account.

Extra Notes:

  • I will try out my Vungle and Admob code over the weekend and see if either is functional and in the case of Admob if it works free or not. I’ll post back when I know more.