Admob test before publishing

How can I test if Admob works on my mobile game before I publish it?

I have incorporated the “showadbanner” blueprint but I do not know how I can test it.

Thank you.

First, use AdMob to get your unit ID for your package name. Add this to the Android project settings and add a “Show Ad Banner” blueprint node. This should be all you need.

If you want to try a test ad without connecting to AdMob servers, you can a test device in GameActivity.java in updateAdVisibility(). Look for:

			AdRequest adRequest = new AdRequest.Builder().build();		// add test devices here

and change it to:

			AdRequest adRequest = new AdRequest.Builder().addTestDevice("deviceserialnumber").build();		// add test devices here

and replace “deviceserialnumber” with the device id from “adb devices”.

Thank you!

Does the “show ad banner” have to be in a specific blueprint or can it be in any of the blueprints I created. For example, if I created a blueprint actor class, can I place the “show ad banner” in that blueprint actor class?

It shouldn’t matter where you place the node; I usually place it in the level blueprint for testing.

“First, use AdMob to get your unit ID for your package name. Add this to the Android project settings and add a “Show Ad Banner” blueprint node. This should be all you need.”

I have done exactly this and have published my app about 3 or 4 different times to Google Play for alpha and beta testing, yet my testers still do not see any ads.
Is it necessary to add the line “addTestDevice(“deviceserialnumber”)” in order for the testers to even see ads? I understand it’s unethical/unlawful to publish actual ads in a testing version, but does AdMob not even send ad data to a Beta version for this reason?

The addTestDevice() part is to see a fake ad during testing which doesn’t contact the admob server. Without this and with a valid admob unit ID it should just work. Are you sure you have copied the unit ID properly? And did you associate the app name with your admob ID on the admob site?

Yes, I literally copied and pasted the unit ID and my app is correctly linked. I’ve remade another admob ad unit where I repeated the app-linking process and still get the same result.

Did you put in your games app id? Also, check the logcat to see if there are any failure messages from the service.

Yes, app ID is in there. Here is as much logcat as I could get after starting to run it on my tablet:

http://pastebin.com/hgaxYrFB

I don’t see it requesting to show the ad. You should see this in the log:

In AndroidThunkJava_ShowAdBanner
AdID: xxxxxx

Check the Config/DefaultEngine.ini and make sure AdMobAdUnitID as set to something (it should be if in the project settings), but this is checked before the ShowAdBanner call is made where the log message is generated.

After doing a Crl+F search of the logcat after trying to run an ad banner on the phone, there was no “ShowAdBanner” or “AdID” string. After scrolling through it there seemed to be nothing related to ads at all. And there is the Ad Unit ID in the DefaultEngine.ini file.
There does seem to be a lot of “Failed to Receive Dispatch Signal” errors throughout the logcat though.

Failed to Receive Dispatch Signal is normal; it is caused by the native glue code in the NDK. You can ignore them.

I’ve tried to boot the app and trigger ads to show multiple times, and every time there is no mention of any ads or ad IDs, not even errors relating to them. Any solution or other test I could try?

Are you working with GitHub source? At this point I believe we need to insert some debug logging to see what is going on.

AndroidAdvertising.cpp is where this starts… try changing FAndroidAdvertisingProvider::ShowAdBanner to this:

void FAndroidAdvertisingProvider::ShowAdBanner( bool bShowOnBottomOfScreen ) 
{
	FPlatformMisc::LowLevelOutputDebugString(TEXT("ShowAdBanner: Entered"));

	FString AdUnitID;
	bool found = GConfig->GetString(TEXT("/Script/AndroidRuntimeSettings.AndroidRuntimeSettings"), TEXT("AdMobAdUnitID"), AdUnitID, GEngineIni);

	if (!found)
		FPlatformMisc::LowLevelOutputDebugString(TEXT("ShowAdBanner: AdMobAdUnitID not found!"));

	if (AdUnitID.IsEmpty())
		FPlatformMisc::LowLevelOutputDebugString(TEXT("ShowAdBanner: AdUnitID is empty!"));


	if (!found || AdUnitID.IsEmpty())
		return;

	extern void AndroidThunkCpp_ShowAdBanner(const FString&, bool);
	FPlatformMisc::LowLevelOutputDebugString(TEXT("ShowAdBanner: Calling to Java thunk"));
	AndroidThunkCpp_ShowAdBanner(AdUnitID, bShowOnBottomOfScreen);
	FPlatformMisc::LowLevelOutputDebugString(TEXT("ShowAdBanner: Returned from calling to Java thunk"));
}

This way we can see if it even tries to show it.

After making the above changes in the “AndroidAdvertising.cpp”, I tried a couple different methods of Showing an ad banner as well as launching my app to the device and observing the logcat. Unfortunately, I still do not see any of the debug messages associated with attempting to launch an admob ad!

Ok, let’s backtrack to the blueprint node call, then:

KismetSystemLibrary.cpp:

void UKismetSystemLibrary::ShowAdBanner(bool bShowOnBottomOfScreen)
{
	FPlatformMisc::LowLevelOutputDebugString(TEXT("UKismetSystemLibrary:ShowAdBanner"));
	if (IAdvertisingProvider* Provider = FAdvertising::Get().GetDefaultProvider())
	{
		FPlatformMisc::LowLevelOutputDebugString(TEXT("UKismetSystemLibrary:Calling Provider->ShowAdBanner"));
		Provider->ShowAdBanner(bShowOnBottomOfScreen);
	}
}

The provider should be AndroidAdvertising from Engine/Config/Android/AndroidEngine.ini:

[Advertising]
DefaultProviderName=AndroidAdvertising

This is what should have called the function you inserted logging into. Maybe the advertising provider isn’t set?

You can try adding this to your project’s Config/DefaultEngine.ini, but it shouldn’t be necessary.

I made the above changes in those files (AndroidEngine.ini already had that defaultprovidername) and put a button in my app that just ran straight to a “ShowAdBanner” node. After publishing and downloading on my device, I opened the logcat and pressed that ad button about 4-5 times and this is what I got (I apologize for the terrible formatting):

I/InputReader(  301): dispatchTouch::touch event's action is 0, pending(waiting finished signal)=0
I/InputDispatcher(  301): Delivering touch to current input target: action: 0, channel '40a8af58 com.WW.RumRunners1/com.epicgames.ue4.GameActivity (serve
I/InputDispatcher(  301): Delivering touch to current input target: action: 0, channel 'PointerDevice-25171 (server)'
E/NativeActivity(25964): channel '40a8af58 com.WW.RumRunners1/com.epicgames.ue4.GameActivity (client)' ~ Failed to receive dispatch signal.  status=-11
I/InputReader(  301): dispatchTouch::touch event's action is 1, pending(waiting finished signal)=0
I/InputDispatcher(  301): Delivering touch to current input target: action: 1, channel '40a8af58 com.WW.RumRunners1/com.epicgames.ue4.GameActivity (serve
I/InputDispatcher(  301): Delivering touch to current input target: action: 1, channel 'PointerDevice-25171 (server)'
E/NativeActivity(25964): channel '40a8af58 com.WW.RumRunners1/com.epicgames.ue4.GameActivity (client)' ~ Failed to receive dispatch signal.  status=-11

If you didn’t see the UKismetSystemLibrary:ShowAdBanner in the logcat, then the Blueprint node was never called. Try putting it in the level blueprint and connecting it to BeginPlay.

Are you sure you recompiled Development Android .so before packaging after these changes?

“Are you sure you recompiled Development Android .so before packaging after these changes?”

I’m not entirely sure how to do this.

hey admob users ! did you success to show interstitial ads?