Admob error

Hi. I have problem with admob. I tried to make a banner ad.

  1. I’m registered on AdMob and I have activated AdMob plugin.

  2. Lua code for the banner ad

local admob = require( “plugin.admob” )

– AdMob listener function
local function adListener( event )
if ( event.phase == “init” ) then – Successful initialization
– Load an AdMob banner ad
admob.load( “banner”, { adUnitId=“ca-app-pub-xxx/xxx” } )
end
end

– Initialize the AdMob plugin
admob.init( adListener, { appId=“ca-app-pub-xxx~xxx” } )

– Sometime later, show the banner ad
if ( admob.isLoaded( “banner” ) ) then
admob.show( “banner”, { y=“top” } )
end

  1. I added to build.settings like here
    https://docs.coronalabs.com/plugin/admob/index.html#project-settings

But the problem is:

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

When it’s added, I have error during the building.


I tried on 3598 and 3582, result is the same.
What can I try now?

Can you tell me in short how to use it?
I need to download this and include to my project?

And I need to add this to my build.settings?

    "plugin.admob" = {
        publisherId = "com.coronalabs",
    },

Thank you in advance for your answer!

Hello,
i am also had problem about admob
i use corona 3582 (xcode 13.4) build to ios. but after build and test by Testfight my app close immediately after open app (crash) , In my opinion had problem especially from adding

plugins =
{
[“plugin.admob”] =
{
publisherId = “com.coronalabs”
},

}, 

What can I try now?

I added:

  		supportedPlatforms = { 
            macos = false,
            win32 = false
        },

And now build works (on 3598), but when I launch app on device I have error:

module ‘plugin.admob’ not found:resource (plugin.admob.lu) does not exist in archive

What I can do? I was reading about self-hosted plugins, but I don’t know what to do ;/

I tried on 3582, but I can’t even build.

Okay, I removed supportedPlatforms and I built on 3583.
No errors, but I don’t see the banner ad… any thoughts?

try on 3595 +

show the full build.settings file

go to users/user/Solar2DPlugins
or users/AppData/Roaming/Solar2DPlugin

u have data.tgz file inside admob? try download the self hosted files and replace?

I got

I/Corona (12988): ERROR: Runtime error
I/Corona (12988): module ‘plugin.admob’ not found:resource (plugin.admob.lu) does not exist in archive
I/Corona (12988): no field package.preload[‘plugin.admob’]
I/Corona (12988): no file ‘(null)/plugin/admob.lua’
I/Corona (12988): no file ‘(null)/plugin/admob.lua’

@vlads @Scott_Harrison can you clear this issue once and for all? how to active ads plugins on new solar2d builds? its bugged, if yes tell us, im fed up with trying to get ads going its been hell

May be it doesn’t have a fill? Also, try launching Console.app (not terminal) there you can select your iPhone and see what gets printed into the output. Filter by your process (you can find a any message from your app, right click and select to show only from this process).
It will may be give some clues on what’s going on.

2 Likes

I can built on 3598 now. But I still can’t see ad.

My build.settings

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

	android =
	{
		usesPermissions =
		{
			"android.permission.INTERNET",
			"android.permission.WRITE_EXTERNAL_STORAGE",
			"android.permission.READ_EXTERNAL_STORAGE",
			"com.android.vending.BILLING",
		},

    applicationChildElements =
    {
      [[
        <meta-data 
        android:name="com.google.android.gms.ads.APPLICATION_ID"
        android:value="ca-app-pub-76899xxx5583xxxx~7xxx63xxxx"/> 
      ]],
    },
	},

	iphone =
	{
		xcassets = "Images.xcassets",
		plist =
		{
			UIStatusBarHidden = false,
			UILaunchStoryboardName = "LaunchScreen",
		},
	},

	plugins =
	{
        ["plugin.google.iap.v3"] =
        {
            publisherId = "com.coronalabs"
        },

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

	excludeFiles =
	{
		-- Exclude unnecessary files for each platform
		all = { "Icon.png", "Icon-*dpi.png", "Images.xcassets", },
		android = { "LaunchScreen.storyboardc", },
	},
}

I test my app on android.

you can remove this

usesPermissions =
{
“android.permission.INTERNET”, <-------------------
“android.permission.WRITE_EXTERNAL_STORAGE”,
“android.permission.READ_EXTERNAL_STORAGE”,
“com.android.vending.BILLING”,
},

the plugin already has internet permission included…

download this

https://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2020/05/plugins_help.zip

run the admob example, in debug mode, u know how to debug yes? go to adb.exe folder and open cmd on that location, then write: adb logcat Corona:v *:s

open the test app and see what it prints

@vlads , I have this sample project of admob, as shown on corona main site:

When using it on public build and forward , for example 2018.3355 , it works as intended, but when using latest Solar2D build, or latest corona daily build, it crashes , or it wont show ads.

HOW do you make it work on latest solar2d release, or stable solar2d release ? what do you got to do? I have admob on my account from the marketplace

After testing my app I have this

--------- beginning of crash
--------- beginning of main
06-05 23:37:21.320 27712 27743 I Corona : WARNING: admob.init(listener, options), init() should only be called once
--------- beginning of system
06-05 23:51:30.827 31653 31685 V Corona : > Class.forName: network.LuaLoader
06-05 23:51:30.828 31653 31685 V Corona : < Class.forName: network.LuaLoader
06-05 23:51:30.828 31653 31685 V Corona : Loading via reflection: network.LuaLoader
06-05 23:51:30.834 31653 31685 I Corona : Platform: SM-A505FN / ARM64 / 10 / Mali-G72 / OpenGL ES 3.2 v1.r19p0-01rel0.###other-sha0123456789ABCDEF0### / 2020.3598 / English | GB | en_GB | en
06-05 23:51:30.849 31653 31685 V Corona : > Class.forName: shared.google.play.services.base.LuaLoader
06-05 23:51:30.850 31653 31685 V Corona : < Class.forName: shared.google.play.services.base.LuaLoader
06-05 23:51:30.850 31653 31685 V Corona : Loading via reflection: shared.google.play.services.base.LuaLoader
06-05 23:51:30.882 31653 31685 V Corona : > Class.forName: licensing.LuaLoader
06-05 23:51:30.886 31653 31685 V Corona : > Class.forName: CoronaProvider.licensing.google.LuaLoader
06-05 23:51:30.886 31653 31685 V Corona : < Class.forName: CoronaProvider.licensing.google.LuaLoader
06-05 23:51:30.891 31653 31685 V Corona : Loading via reflection: CoronaProvider.licensing.google.LuaLoader
06-05 23:51:30.938 31653 31685 V Corona : > Class.forName: plugin.admob.LuaLoader
06-05 23:51:30.938 31653 31685 V Corona : < Class.forName: plugin.admob.LuaLoader
06-05 23:51:30.939 31653 31685 V Corona : Loading via reflection: plugin.admob.LuaLoader
06-05 23:51:32.257 31653 31653 I Corona : plugin.admob: 1.2.6 (SDK: 12451000)
06-05 23:51:41.847 31653 31685 I Corona : WARNING: admob.init(listener, options), init() should only be called once
06-05 23:51:53.937 31653 31685 I Corona : WARNING: admob.init(listener, options), init() should only be called once
06-05 23:52:48.989 31653 31685 I Corona : WARNING: admob.init(listener, options), init() should only be called once

Now I tested admob from plugins_help
I see no ad, there’s what I get

06-06 00:30:56.652 11811 11848 V Corona : Loading via reflection: plugin.admob.LuaLoader
06-06 00:30:58.138 11811 11811 I Corona : plugin.admob: 1.2.6 (SDK: 12451000)
06-06 00:30:58.176 11811 11848 I Corona : phase init
06-06 00:30:58.176 11811 11848 I Corona : provider admob
06-06 00:30:58.176 11811 11848 I Corona : name adsRequest
06-06 00:30:58.176 11811 11848 I Corona : isError false
06-06 00:30:58.176 11811 11848 I Corona : ---------------------------
06-06 00:31:58.726 11811 11848 I Corona : type banner
06-06 00:31:58.726 11811 11848 I Corona : name adsRequest
06-06 00:31:58.726 11811 11848 I Corona : provider admob
06-06 00:31:58.726 11811 11848 I Corona : phase failed
06-06 00:31:58.726 11811 11848 I Corona : isError false
06-06 00:31:58.726 11811 11848 I Corona : data {“errorMsg”:“Network Error”,“errorCode”:2,“adUnitId”:“ca-app-pub-7689xxx55xxxx402/15xx87xxxx”}
06-06 00:31:58.727 11811 11848 I Corona : response loadFailed
06-06 00:31:58.727 11811 11848 I Corona : ---------------------------

What it means?

Looks like you’re calling init() too many times.

Are you doing it in composer scene? That is not the right way to do it.

You should call init() in main.lua or a module called from main, then wait for a response before trying to load and show ads.

I believe there is a demo for adMob. Have you tried using that demo with your IDs?

1 Like

This means the load failed. Is that all the event fields in the event passed to the the listener?

Also, have you used admob without a filter? i.e. don’t filter for just Corona messages. There may be more details in an filtered log.

1 Like

@roaminggamer I call init() in main.lua, then I go to welcome screen, and then after click I go to menu with saves, where I want the banner. Now I’m using test ad from here.

main.lua (where I init and load)

local admob = require( “plugin.admob” )

local function adListener( event )
if ( event.phase == “init” ) then
admob.load( “banner”, { adUnitId=“ca-app-pub-3940256099942544/6300978111” } ) – it’s demo banner
end
end

– Initialize the AdMob plugin
admob.init( adListener, { appId=“ca-app-pub-76xx96xxxx832xxx~730xx34xxx” } )

local composer = require “composer”
composer.gotoScene(“welcomeScreen”)

menu.lua with saves (where I want the banner)

local admob = require( “plugin.admob” )

if ( admob.isLoaded( “banner” ) ) then
admob.show( “banner” )
end

And test banner from Google works! Now I’m trying with my banner ID.

Nah… not working with my banner.
But I haven’t configure my payments on AdMob yet and I’ve read that this may be the reason it isn’t working.

When I try get messages without filter, I have so many logs that I can’t read anything.

what corona version you use? how you installed the plugin? what did you do ?

@tal_nahum, I use 3598. I made build.settings, main.lua (init and load) and menu.lua (show). Just like above.

I tried banner and interstitial. Test AdMob ads works fine. When I try to run my ads, I have this in logcat:

06-06 15:00:47.681 2458 2458 I Corona : plugin.admob: 1.2.6 (SDK: 12451000)
06-06 15:00:47.712 2458 2509 I Corona : phase init
06-06 15:00:47.712 2458 2509 I Corona : provider admob
06-06 15:00:47.712 2458 2509 I Corona : name adsRequest
06-06 15:00:47.712 2458 2509 I Corona : isError false
06-06 15:00:47.712 2458 2509 I Corona : ---------------------------
06-06 15:00:48.884 2458 2509 I Corona : type interstitial
06-06 15:00:48.885 2458 2509 I Corona : name adsRequest
06-06 15:00:48.885 2458 2509 I Corona : provider admob
06-06 15:00:48.885 2458 2509 I Corona : phase failed
06-06 15:00:48.885 2458 2509 I Corona : isError false
06-06 15:00:48.885 2458 2509 I Corona : data {“errorMsg”:“No Ads Available”,“errorCode”:3,“adUnitId”:“ca-app-pub-768xxx3x5xxxxx2/54x35xxxxx”}
06-06 15:00:48.887 2458 2509 I Corona : response loadFailed
06-06 15:00:48.887 2458 2509 I Corona : ---------------------------

No Ads Available - what does it mean? No fill?

I have the same, you did something with those files?

or you just added admob to your account and build.settings ?

for your current error, try to build and test your app on public build:

CoronaSDK 2018.3326

tell me if it is showing ads (not on test mode)

No, finally I downloaded the 3598 and I activated admob plugin on marketplace.

My build.settings

settings =
{
orientation =
{
– Supported values for orientation:
– portrait, portraitUpsideDown, landscapeLeft, landscapeRight
default = “portrait”,
supported = { “portrait” },
},

android =
{
usesPermissions =
{
“android.permission.WRITE_EXTERNAL_STORAGE”,
“android.permission.READ_EXTERNAL_STORAGE”,
“com.android.vending.BILLING”,
},

applicationChildElements =
{
  [[
    <meta-data 
    android:name="com.google.android.gms.ads.APPLICATION_ID"
    android:value="ca-app-pub-768xxxx55xxxxx~82xxxxxx"/> 
  ]],
},

},

iphone =
{
xcassets = “Images.xcassets”,
plist =
{
UIStatusBarHidden = false,
UILaunchStoryboardName = “LaunchScreen”,
},
},

plugins =
{
[“plugin.google.iap.v3”] =
{
publisherId = “com.coronalabs”
},

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

},

excludeFiles =
{
– Exclude unnecessary files for each platform
all = { “Icon.png”, “Icon-*dpi.png”, “Images.xcassets”, },
android = { “LaunchScreen.storyboardc”, },
},
}

Do you have " “errorCode”: 3 " too?
I find something about that error here.
Maybe the problem is that I test it on “Internal app sharing” on Google Play?

I will test it on public build.

On 2018.3326 result is the same.
Maybe there is problem with AdMob, not with Corona/Solar2D?

I have found out that testing the admob sample code (with test mode off) I do get ads… but on my app I don’t, it says error code 3, the only difference is the keystore settings which on my app is mine, and on the sample app its debug.keystore… so I guess it has to do with this… im checking it further now