[OUTDATED][Free] Admob Extension - Add different types of AdMob ads in your application

It seems you are not well informed. The original text was in all caps and he later changed it. So no need to respond for someone else if you don't know what happened. :wink:

3 Likes

Oh thanks! :wink:

So you are trying this on Companion? This extension doesn't work on companion as companion doesn't have required manifest.
It should work fine if you use as application.

2 Likes

Hello, I tested installing the app on my cell phone, but the error continued, I did the same as the video tutorial, but I analyzed your code and found where the problem was and now it is working correctly. Thank you very much for your support and attention.

1 Like

The error only come if you use companion or you don't have added and dragged AdmobSdk extension as service version is added on that extension's manifest. Code :

However, you can share how you solved the problem so that user with similar problem can look over to your solution.

You are welcome !

3 Likes

My Nitotron wont compile in the first place. Any ideas whats causing the porblem?

package admob.purplemango.admobid;

import android.app.Activity;
import android.content.Context;
import com.google.appinventor.components.annotations.*;
import com.google.appinventor.components.common.ComponentCategory;
import com.google.appinventor.components.runtime.AndroidNonvisibleComponent;
import com.google.appinventor.components.runtime.ComponentContainer;
import com.google.appinventor.components.runtime.EventDispatcher;
import com.google.appinventor.components.annotations.androidmanifest.*;
@DesignerComponent(
        version = 1,
        description = "",
        category = ComponentCategory.EXTENSION,
        nonVisible = true,
        iconName = "")

@SimpleObject(external = true)
//Libraries
@UsesLibraries(libraries = "")
//Permissions
@UsesPermissions(permissionNames = "")
@UsesApplicationMetadata(metaDataElements={@MetaDataElement(name="com.google.android.gms.ads.APPLICATION_ID", value="ca-app-pub-1058145014713648/6484169250")})
public class PurpleMango extends AndroidNonvisibleComponent {

    //Activity and Context
    private Context context;
    private Activity activity;

    public PurpleMango(ComponentContainer container){
        super(container.$form());
        this.activity = container.$context();
        this.context = container.$context();
    }

    @SimpleFunction(description = "Sample Function Generated by Niotron")
    public void TestFunction(){

    }

    @SimpleEvent(description = "Test Event Generated by Niotron")
    public void TestEvent(){
        EventDispatcher.dispatchEvent(this, "TestEvent");
    }
}



1 Like

You should really be asking on the Niotron community about this....

4 Likes

I used the code you added in your reply and the extension is successfully compiling.
PurpleMango.aix (5.5 KB)

Added FAQs on documentation.


FAQs:

How to create an AdMob Account ?
  • Go to AdMob Home, Click on Get Started or SignUp. If you have already created an AdMob account earlier, do not create a new account instead login with that account.

  • If you access this link in a browser where you have already login with a Google account you will receive this screen. Where they ask you to verify your account click Next .

  • Place the password and Click the Next button.

  • Now place the required information, on Country, Time zone & Billing Currency.

  • Click the Create AdMob Account button after adding all information.
    image

  • Check the email notifications for your account. And continue to next screen.

  • Now your AdMob Account is created. You should create an app & then ad unit id for the ads to show.

How to create an application Id & Ad Unit Id ?
  • Click on Apps on SideBar and then click on Add Your First App .

  • Set Platform to Android and check if your app is listed on supported app store or not.

  • If your app is already published to listed stores then search for your app, submit and continue.


    If you have checked no then add an app name then click on AddApp & click on Done.

  • Now, Click on Add Ad Unit.

  • Now, Select an ad format, in this case I am selecting Banner,

  • Add an ad unit name, and click on Create ad unit.

  • Now, your ad unit is created sucessfully. You will find appId & adUnit id. Copy these id somewhere in notepad and save this. You can use the app id while creating your extension for manifest requirement for the application. And you can use ad unit id in the respective format extension.
    image

Where do I find my app id and AdMob ad unit id ?

I've found most user are confused on AdMob app id & ad unit id. AppId and ad unit id are different. You should use your app id when you are building your own extension from Niotron IDE & you should use ad unit id in your respective ad extensions for banner, interstitial and all.

Copied from Google AdMob Support, Find more.

Find an app ID

  1. Sign in to your AdMob account at https://apps.admob.com.
  2. Click Apps in the sidebar.
  3. Click View all apps.
  4. Click the Copy icon in the App ID column to copy the ID of an app

Find an ad unit ID

  1. Sign in to your AdMob account at https://apps.admob.com.
  2. Click Apps in the sidebar.
  3. Click the name of the app associated with the ad unit. Note: If you don't see it in the list of recent apps, click View all apps. Then, click the name of the app.
  4. Click Ad units in the sidebar.
  5. Click the Copy icon in the Ad unit ID column to copy the ID of an ad unit.
How to enable test ads ?

It's important to enable test ads during development so that you can click on them without charging Google advertisers. If you click on too many ads without being in test mode, you risk your account being flagged for invalid activity.

In every format extension ie, AdmobBanner, AdmobInterstitial, AdmobRewarded etc you will find TestMode checkbox on their properties. You should check the checkbox in order to enable test ads.

image

Or,

Extension is not working on Companion, Why?

This extension will not work on companion as companion application doesn't have required manifest for the extension to work. You should always build the application to check if it is working or not. So, I will suggest you to complete your application and use this extension after.

Ads are only showing on test mode, When I put my own ad unit id, It doesn't show ads, Why?

Many users have complained that this extension is not able to show their ads with their ad unit id. First of all, you should be sure if you haven't violated any of the AdMob policies and your AdMob is allowed to serve the ads. You should be sure that you have followed all the steps from documentation properly. Some users use ad-unit as app-unit or vice-versa. Make sure your are not that user and have used appId(which contains ~) while creating extension in Niotron IDE as suggested & adUnitId(which contains /) properly in Admob Banner, Interstitial or Rewarded ad extension.

Secondly, If your ad is failed to load then get the failure message from AdFailedToLoad method. If the failure message is no-ad-config then you can check a FAQ on this documented after this FAQ. You can reply this post if you got any trouble.

Ad loading failed with an error 'No Ad Config', How to fix?

Most users get this message after they completed all the steps on documentation,

{
  "Code": 3,
  "Message": "No ad config.",
  "Domain": "com.google.android.gms.ads",
  "Cause": "null",
  "Response Info": {
    "Response ID": "null",
    "Mediation Adapter Class Name": "",
    "Adapter Responses": []
  }
}

You don't need to worry about this. If the app is not published on Play Store then first make sure you have followed steps properly then you can publish your app and wait few days.

Also, Kindly ensure that the following conditions are fulfilled in order to maximize the chances of receiving ads from the AdMob SDK:
Copied from Google Groups, See

You may also refer to common reason for ads not showing for additional scenarios, as well as the fixes for those. Also, you may also reach out to the AdMob Help Center for further assistance on such ad-serving concerns.

3 Likes

Why this error


I've explained this on FAQs. This is because your adUnit is not able to serve ads now. Publish your application on PlayStore, register that app on your AdMob and wait for a few days.
Also, you should not test the real ads on your own device. You can use the second method on How to enable test ads? of FAQs to enable test ads for your device.

Make sure you have used the correct ad ids and app id. If you are coming from the TheCodingBus youtube video on AdMob, then he has done some mistake there, he has used AdUnit instead of AppId while creating an extension.

How to create an application Id & Ad Unit Id ?
  • Click on Apps on SideBar and then click on Add Your First App .

  • Set Platform to Android and check if your app is listed on supported app store or not.

  • If your app is already published to listed stores then search for your app, submit and continue.


    If you have checked no then add an app name then click on AddApp & click on Done.

  • Now, Click on Add Ad Unit.

  • Now, Select an ad format, in this case I am selecting Banner,

  • Add an ad unit name, and click on Create ad unit.

  • Now, your ad unit is created sucessfully. You will find appId & adUnit id. Copy these id somewhere in notepad and save this. You can use the app id while creating your extension for manifest requirement for the application. And you can use ad unit id in the respective format extension.
    image

Where do I find my app id and AdMob ad unit id ?

I've found most user are confused on AdMob app id & ad unit id. AppId and ad unit id are different. You should use your app id when you are building your own extension from Niotron IDE & you should use ad unit id in your respective ad extensions for banner, interstitial and all.

Copied from Google AdMob Support, Find more.

Find an app ID

  1. Sign in to your AdMob account at https://apps.admob.com.
  2. Click Apps in the sidebar.
  3. Click View all apps.
  4. Click the Copy icon in the App ID column to copy the ID of an app

Find an ad unit ID

  1. Sign in to your AdMob account at https://apps.admob.com.
  2. Click Apps in the sidebar.
  3. Click the name of the app associated with the ad unit. Note: If you don't see it in the list of recent apps, click View all apps. Then, click the name of the app.
  4. Click Ad units in the sidebar.
  5. Click the Copy icon in the Ad unit ID column to copy the ID of an ad unit.

Check this FAQs :

hello, i'm aditama from id :indonesia:
I want to ask, does admob sdk need to be installed on all screens with ads or just screen 1?
@oseamiya

1 Like

No need. If you already have dragged and dropped the SDK extension on Screen1 then you are good to go.

Also, you don't need to initialize the SDK on another screen if you have already initialized it on Screen1.

1 Like

Thank you very muchhhh........ :blush: :blush: :blush:
@oseamiya

1 Like

Added Facebook Audience Network In Mediation

Documentation on first post is updated too.


To integrate Facebook Audience Network, You should follow these steps.

Step 1 : Set up Facebook Audience Network

  • Sign up and Log in to the Business Manager Start page.

  • Click Create a new Business Manager account and fill out the required fields with your business details.

  • Once you've filled out the required information, you'll be prompted to create a property for your app. Enter the desired name of the property for your app and click. Then Go to Monetization Manager .

  • Next, select Android as the platform to monetize.

  • Indicate whether or not your app is live and click Submit . Then, You will be prompted to create an ad placement for your application. Select a format, fill out the form and click Next .

  • Now, Note your System user access token and placement id

  • Note the property id of your product
    If you look at the link on monetization manager then it looks like that

https://business.facebook.com/pub/property/?business_id=1285496463872947&property_id=631234567890471&ref=devsite_app_onboarded

Note property id after &property_id= to &ref= . For this link above, 631234567890471 is my property id. Note the property id.

Step 2 : Create a new Mediation Group

  • First, You should create an application on AdMob and create all placements you have made on Monetization Manager. Please check FAQs at end of documentation if you don't know how to create application id and ad unit id.

  • Now tap on Mediation >> Mediation Groups and click on Create Mediation Group

  • Enter the ad format, for example if you have created 2 placements, one banner and one interstitial in Montization manager, we will create for banner first then interstitial.

  • Give your mediation group a name, and select locations to target. Next, set the mediation group status to Enabled. Then click Add Ad Units, which will open up the ad unit selection overlay.

  • Choose that App and AdUnit that we will use to integrate facebook ads on.

  • Then on Biddings, Click on Add ad source, Select facebook audience network and add placement id that we created on Step1. Then click Done.

  • Then on Waterfall, Click on Add ad source, Select Facebook Audience Network, then add manual cpm for example 1$ , Continue and add placement id, system access token and property id that we have noted on Step 1.

Step 3 : Drag and Drop FacebookBidding Extension

  • You should download FacebookBidding extension, and just drag and drop that extension to Screen. This extension doesn't contain any methods. You must use AdMob Sdk extension and that extension we created on Niotron IDE to put app id on manifest. And if you want to show facebook banner ad, you can download banner ad extension from above. You should use ad unit id of that AdmobApp we mediate our facebook on.

    Download Latest Version Of FacebookBidding Extension From Github

Step 4: Upload a dex file

Source Code

1 Like

Added AdColony Ad with mediation.
Documentation on the first post is updated too.

Supported Ad Formats:

* Banner
* Interstitial
* Rewarded 
* Native 

To integrate AdColony ads with mediation, you should follow these steps :

Step 1 : Setup Ad Colony

  • Sign up and log in to your AdColony account. Add your app to the AdColony publisher dashboard by clicking the Setup New App button.

    AdColony setup new app

  • Fill out the form and click Create at the bottom of the page to add your app to AdColony.

    AdColony create app

  • Once your app is created you can obtain your App ID by navigating to Monetization > Apps under your app's Basic App Information section.

    AdColony app id

  • Next, create a new Ad Zone by clicking the Setup New Ad Zone button in the Ad Zones section of your App's page. We recommend creating a new Ad Zone for mediation with AdMob even if you already have one.

    AdColony set up zone

  • Set Zone is Active? to Yes and Enter a Name for your AdZone.

  • For Banner, Choose Banner as the Ad Zone Size.

  • Enter a value for the Daily play cap.

  • Click the Create button when finished to create the Ad Zone. Note your AdZone and app id in notepad. It will be used on further steps.

  • Now, Go to Settings and note the Read-Only API key in notepad. It will be used on further steps.

Step 2: Create & Configure Mediation Group

  • Go to mediation and create a new mediation group.

  • Enter your ad format and platform, then click Continue.

  • Give your mediation group a name, and select locations to target. Next, set the mediation group status to Enabled. Then click Add Ad Units, which will open up the ad unit selection overlay.

    New mediation group 2

  • Associate this mediation group with your existing AdMob ad unit. Then click Done.

  • Now under bidding card, tap on Add ad source then select AdColony then paste the zone id we have copied earlier.

  • Then, under waterfall card, tap on Add ad source then select AdColony and then add app id , zone id and API key.

  • Click Save.

Step 3: Drag & Drop Adcolony Mediation Extension

I've added all the required libraries for showing AdColony ads in this extension. You just need to download, drag and drop the extension to the screen. This extension doesn't contain any methods.

Download Latest Version Of AdColonyMediation extension from Github

Source :

1 Like

Anyone of you can tell what to do when ad is clicked? When ad will be clicked what will be happened?
If someone click the ad then the website which is in the ad should be opened in external browser? How to do it?

It will redirect to the advertiser website / content.

You don't need to redirect to content manually. AdClicked event can be useful if you want to show something or refresh ads after Ad is clicked.

1 Like

Ohhh thank you so much. I was woried that i didn't set the on click or on open ad function. Again thanks.