Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

From The Blog: Important AdMob and other ad plugin changes
Started by CoronaBot Jul 22 2019 07:42 AM

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

CoronaBot

[GLOBAL: userInfoPane.html]
CoronaBot
  • Contributor

  • 430 posts
  • Corona Staff

It seems that all of our news lately has been wrapped around Google, and so it is again. AdMob has update their libraries again, and in doing so, created a breaking change. Your app’s App Id previously was only needed at the time you initialized the plugin. Google is now looking for it inside the AndroidManifest.XML file. If you wish to use AdMob as well as Appodeal (since it includes AdMob), you must add this to your build.settings:

settings =
{
    android =
    {
        applicationChildElements =
        {
            [[
                <meta-data android:name="com.google.android.gms.ads.APPLICATION_ID"
                    android:value="[YOUR_ADMOB_APP_ID]"/>  -- replace with your app id. See: https://goo.gl/fQ2neu
            ]],
        }
    },
    plugins =
    {
        ["plugin.admob"] =
        {
            publisherId = "com.coronalabs"
        },
    },
}

Simply replace the [YOUR_ADMOB_APP_ID] with your actual App ID inside the quotes and with out the square brackets.

In addition, many of you are still referencing the old legacy AdMob plugin since it was a dependency for many other ad plugins. Please look through your build.settings and remove any references to:

["plugin.google.play.services"]

If you do not remove this, your build will fail and you should get an error message in your console using the latest builds.

You should make these changes before your next attempt to build for Android. See the AdMob implementation documentation for more details.


View the full article

[TOPIC: post.html]
#2

hogletpie

[GLOBAL: userInfoPane.html]
hogletpie
  • Contributor

  • 152 posts
  • Corona SDK

Is it safe to assume that for my (iOS) apps (that use the paid AdMob plugin) that have not been updated since 2017 then there is no need to update?

 

Thanks!



[TOPIC: post.html]
#3

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 26,408 posts
  • Enterprise

No, it's not safe to assume that. Google apparently made a backend changes that cased rewarded videos to start failing. Updating to newer plugins (with newer SDKs) seem to have addressed these issues.

 

If you're not using rewarded video, you may be safe for now.

 

Rob



[TOPIC: post.html]
#4

hogletpie

[GLOBAL: userInfoPane.html]
hogletpie
  • Contributor

  • 152 posts
  • Corona SDK

Thanks very much for the reply. I am not using rewarded video and the interstitial ads (static and video) and banners are showing as of July 23rd 2019.

 

Thanks!



[TOPIC: post.html]
#5

Aarbron

[GLOBAL: userInfoPane.html]
Aarbron
  • Contributor

  • 109 posts
  • Corona SDK

Hello!

 

We got to use the exact same code (copy paste) for iOS builds?

Also can we change the order and do something like this?

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

    android =
    {
        applicationChildElements =
        {
            [[
                <meta-data android:name="com.google.android.gms.ads.APPLICATION_ID"
                    android:value="[YOUR_ADMOB_APP_ID]"/>  -- replace with your app id. See: https://goo.gl/fQ2neu
            ]],
        }
    },
}

edit!

One more question please!

Are we allowed to do this too?

Using android twice, at the top and bottom of code.

settings =
{
    android =
    {
        applicationChildElements =
        {
            [[
                <meta-data android:name="com.google.android.gms.ads.APPLICATION_ID"
                    android:value="[YOUR_ADMOB_APP_ID]"/>  -- replace with your app id. See: https://goo.gl/fQ2neu
            ]],
        }
    },

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

    android =                
    {
        versionCode = "100",
        
    },
}


[TOPIC: post.html]
#6

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 26,408 posts
  • Enterprise

For iOS, you do not need the applicationChildElements. This is in the android table, which means it's only used during android builds.

 

You may only have one android subtable in build.settings, the second one would overwrite the first.

 

Rob



[TOPIC: post.html]
#7

Aarbron

[GLOBAL: userInfoPane.html]
Aarbron
  • Contributor

  • 109 posts
  • Corona SDK

How about the order?

Does it matter which block of code (plugins, android) is first or second?

I'm asking because I want to have the plugins on top and android after.

 

Also the "APPLICATION_ID" is the the same as the package name?

com.mycompany.mygame



[TOPIC: post.html]
#8

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 26,408 posts
  • Enterprise

Lua tables, the order of items doesn't matter. The keys tend to be presented in random order anyway.

 

Feel free to put the plugin block at the top.

 

In this case com.google.android.gms.ads.APPLICATION_ID is a key with that exact name. You should not substitute anything for APPLICATION_ID.

 

Rob



[TOPIC: post.html]
#9

Aarbron

[GLOBAL: userInfoPane.html]
Aarbron
  • Contributor

  • 109 posts
  • Corona SDK

I'm stupid.

Thank you Rob.



[TOPIC: post.html]
#10

d.mach

[GLOBAL: userInfoPane.html]
d.mach
  • Contributor

  • 918 posts
  • Corona SDK

For iOS, you do not need the applicationChildElements. This is in the android table, which means it's only used during android builds.

 

You may only have one android subtable in build.settings, the second one would overwrite the first.

 

Rob

 

Does this mean older iOS apps using admob don't need an update?



[TOPIC: post.html]
#11

d.mach

[GLOBAL: userInfoPane.html]
d.mach
  • Contributor

  • 918 posts
  • Corona SDK

 

admob-2-1-150x150.pngIt seems that all of our news lately has been wrapped around Google, and so it is again. AdMob has update their libraries again, and in doing so, created a breaking change. Your app’s App Id previously was only needed at the time you initialized the plugin. Google is now looking for it inside the AndroidManifest.XML file. If you wish to use AdMob as well as Appodeal (since it includes AdMob), you must add this to your build.settings:

settings =
{
    android =
    {
        applicationChildElements =
        {
            [[
                <meta-data android:name="com.google.android.gms.ads.APPLICATION_ID"
                    android:value="[YOUR_ADMOB_APP_ID]"/>  -- replace with your app id. See: https://goo.gl/fQ2neu
            ]],
        }
    },
    plugins =
    {
        ["plugin.admob"] =
        {
            publisherId = "com.coronalabs"
        },
    },
}

Simply replace the [YOUR_ADMOB_APP_ID] with your actual App ID inside the quotes and with out the square brackets.

In addition, many of you are still referencing the old legacy AdMob plugin since it was a dependency for many other ad plugins. Please look through your build.settings and remove any references to:

["plugin.google.play.services"]

If you do not remove this, your build will fail and you should get an error message in your console using the latest builds.

You should make these changes before your next attempt to build for Android. See the AdMob implementation documentation for more details.


View the full article

 

 

Can you please post a sample for the correct replacements? It's a little bit difficult to figure this out.



[TOPIC: post.html]
#12

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 26,408 posts
  • Enterprise

settings =
{
	orientation =
	{
		default = "portrait",
		supported = { "portrait" }
	},
	splashScreen = 
	{
		enable = false
	},
	android =
	{
		usesPermissions =
		{
			"android.permission.INTERNET",
			"android.permission.ACCESS_NETWORK_STATE",
			"android.permission.WRITE_EXTERNAL_STORAGE",
		},
		applicationChildElements =
        {
            [[
                <meta-data android:name="com.google.android.gms.ads.APPLICATION_ID"
                    android:value="ca-app-pub-5387163376908424~XXXXXXXXXXXX"/>  -- replace with your app id. See: https://goo.gl/fQ2neu
            ]],
        }
	},
	iphone =
	{
                xcassets = "Images.xcassets",
		plist =
                {
			NSCalendarsUsageDescription = "",
			NSAppTransportSecurity = { NSAllowsArbitraryLoads=true },
			NSLocationAlwaysUsageDescription = { "" },
			NSLocationWhenInUseUsageDescription = { "" },
			NSPhotoLibraryUsageDescription = "This app does not access the photo library.",
			NSCameraUsageDescription = "This app does not use the camera.",
			UILaunchStoryboardName = "LaunchScreen",
		}
	},

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

    },
}

Hopefully this helps.

 

Rob



[TOPIC: post.html]
#13

d.mach

[GLOBAL: userInfoPane.html]
d.mach
  • Contributor

  • 918 posts
  • Corona SDK

Thanks for the info! Is the iphone part from the code above needed for iOS versions with new builds and updates?



[TOPIC: post.html]
#14

d.mach

[GLOBAL: userInfoPane.html]
d.mach
  • Contributor

  • 918 posts
  • Corona SDK

One more question because of the XXXXXXX part:

android:value="ca-app-pub-5387163376908424~XXXXXXXXXXXX"/> -- replace with your app id.

The sample is showing the number 5387163376908424 but when using this for with my own new build I have to replace the whole content in the brackets, right?

 

So this should all be replaced like this?... ca-app-pub-XXXXXXXXXXXXXXXX~XXXXXXXXXX



[TOPIC: post.html]
#15

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 26,408 posts
  • Enterprise

I tried to show you as much of a valid App ID that I was comfortable showing. Replace the 

 

ca-app-pub-XXXXXXXXXXXXXXXX~XXXXXXXXXX

 

with the value you get in the AdMob developer console. It should be inside the quotes the /> at the end is important (as it closes an XML element on the previous line.

 

Rob



[TOPIC: post.html]
#16

d.mach

[GLOBAL: userInfoPane.html]
d.mach
  • Contributor

  • 918 posts
  • Corona SDK

Thank you!!!



[TOPIC: post.html]
#17

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 26,408 posts
  • Enterprise

The iOS portion hasn't changed in a while and should work with modern versions of Corona and iOS builds.

 

Rob



[TOPIC: post.html]
#18

d.mach

[GLOBAL: userInfoPane.html]
d.mach
  • Contributor

  • 918 posts
  • Corona SDK

Can anybody confirm that admob is working correctly on Android with this new changes in the build.settings? Interstitials and rewarded ads?



[TOPIC: post.html]
#19

Aarbron

[GLOBAL: userInfoPane.html]
Aarbron
  • Contributor

  • 109 posts
  • Corona SDK

Yes it works great for me. Interstitials and rewarded.

Tested on many apps.

My personal apps and my customers.

I haven't tested with 64bit!

Maybe somebody else can post about 64bit.



[TOPIC: post.html]
#20

d.mach

[GLOBAL: userInfoPane.html]
d.mach
  • Contributor

  • 918 posts
  • Corona SDK

Yes it works great for me. Interstitials and rewarded.

Tested on many apps.

My personal apps and my customers.

I haven't tested with 64bit!

Maybe somebody else can post about 64bit.

 

Thank you for the info. Did you use a 64bit ready build version of Corona?



[TOPIC: post.html]
#21

Aarbron

[GLOBAL: userInfoPane.html]
Aarbron
  • Contributor

  • 109 posts
  • Corona SDK

Nope.

I use the 2019.3480 version.

I would like to know more about 64bit too.



[TOPIC: post.html]
#22

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 26,408 posts
  • Enterprise

Questions regarding Android 64-bit are best asked in the Corona 64-bit testing forum.

 

Rob




[topic_controls]
[/topic_controls]