How to embed ads in android app. How to add admob ads to android phonegap app. AdToApp advertising platform aggregator

We enter "AdMob" into Google and the first site will no longer be AdMob, but Google's site. After switching to it, you will be gradually lured to the dark side of Firebase (recently bought by Google).

Firebase provides quite extensive analytics (at least for me, as a programmer, not a marketer) of advertising in your application (height, weight, country, number of views, Android version where it was installed, etc. etc.).

First of all, it was found, but it is for Eclipse, and after the first attempts to follow the example, warnings about depricated and, in general, errors began.

After reading more information, it became clear that the transition of AdMob to firebase happened recently and you will have to figure it out yourself.

Let's see how to live with it now

Minimum requirements: (with which the article was written).
  • Android Studio 2.2.2
  • Be registered in the Google Developer Console
  • Be registered with AdMob
Step 1
Add dependencies to build.gradle files. First thing in "Module: app":


Now in the second one ("Project: AdMobOnHabr"):


After that, it is recommended to do Tools → Android → "Sync Project with Gradle Files" and compile the project. There is no visible result yet, but the main thing is there are no mistakes? Excellent! Move on.
Step 2
Login to your AdMob account. We choose to manually add the application (if your application is already published on Google Play, use the search in the first tab).


Let's add an ad to our application banner(I suggest that you familiarize yourself with other types). Refresh rate I chose the minimum allowable - 30 sec., the name of the ad unit is up to you.


Next, you will be prompted to "Set up Firebase Analytics ( not necessary)" - underlined the right word. So far, it's useless skip. We get acquainted with the "instructions for integration", click Ready. After the redirect, we see the page and the long-awaited ID of the ad unit:


Adding ad unit ID in strings.xml:


Don't forget that an ad unit on another Activity needs a new ID.
Step 3
Add an AdView element to activity_admobbanner.xml:


In the attribute "ads:adUnitId" we write the resource from strings.xml with ad unit ID.

A few tips and notes:

Step 4
Initializing the Google Mobile Ads SDK. To do this, you will need an app ID taken from AdMob. Click gear top right → Application management:


Here it is, happiness is the desired app ID:


We write the initialization itself using our app ID:

Step 5
The last action according to Google is to load the long-awaited ad in the AdView element:


On the emulator, following the AdMob policy, you cannot display real ads (only test ads are shown). Pretty logical. But if you have a real device, you can test the ad in action on it and please yourself with success.



It seems that everything was done as written, everything should work, and it’s time for us to go to bed to work on the next feature, but ...
Step 6
Somewhere between the lines You should have read that without google-services.json it won't work. Most likely, you do not have this file yet. Let's search together.

Google kindly provides you with "sheets" of instructions on how to do google-services.json. But I had a question - do you really need to sit and write this file yourself in 2k16, which, on top of everything, is most likely rather stereotyped?

The answer is in the Google Developer Console, where they still thought about the desire of a lazy programmer.

Fill in the fields:


Click Continue. Choose Google Sing-In. Then it's simple - you know your SHA-1 by heart, don't you?


If you suddenly forgot - I can help. SHA-1 can be found using keyltool or a little clumsy - through gradle in the AS itself. Since we don’t want to do unnecessary actions, we will choose the second method:

  1. Click on the Gradle side tab (on the right in the AS window);
  2. Select your project (if necessary, click Refresh);
  3. Open Tasks -> android;
  4. Double click on signingReport;
  5. Switch to text display mode Run console (see screenshot below);
  6. Don't forget to select your application for the build later (and not signingReport);
And here is your SHA-1. Remembered?


Paste the received SHA-1 code, click "Enable Google Sign-In" and "Continue to Generate configuration files".


Well, you get the idea. Download the generated file and copy it to the root directory of the application:


Putting together your project ready. Through similar simple manipulations, your application now has ads.

P.S.: Code in pictures, so that people remember something, and not just copy-pasted in a few seconds.

PhoneGap is a tool that allows you to develop applications in JavaScript and convert them to native applications on mobile platforms (such as Android and iOS). AdMob is a platform for connecting advertising banners to your application for views and clicks on which you can earn money. Here I will tell you how to connect ads from Google AdMob to Android PhoneGap application. To do this, you need to do the following

1. Register with AdMob and get a Publisher ID to connect an advertising banner.
2. Make changes to the Android project to display an advertising banner

1. Registration in AdMob and getting a Publisher ID to connect advertising.

1. Go to the site http://www.google.com/ads/admob/
2. Select Add Site / App from the menu
3. Choose Android App
4. Fill in App Name, Category and App description. It is not necessary to fill in the Android Package URL until our application is on Google Play. Leave this field completely empty. (You need to remove from the field what is already entered there by default - this is market://)
5. Click OK
6. Next, you will see a screen where you are prompted to download the AdMob Android SDK. We'll download the AdMob SDK later, for now, click here Go to Sites/Apps.
7. You now see a list of your applications. Find the app you just added and hover your mouse over its name. You will see the Manage Settings button appear. We press it.
8. Now we see the Publisher ID. its value will need to be inserted as the value of the AdMob_Ad_Unit field in our Android application.

2. Connecting AdMob to an Android project

Download AdMob SDK here

After downloading, you need to put the downloaded file in the libs folder of our android project.


1. If we are working in Intellij Idea, then right-click on the added jar file and select Add as Library...
2. If we are working in Eclipse, then we right-click on the project and select Build Path --> Configure Build Path. Now select the Libraries tab and click the Add Jars button. Choose yourProject/libs/GoogleAdMobAdsSdk-*.*.*.jar

In the main java file of your android application, you need to add the following.
1. Add to import
import com.google.ads.* ; import android.widget.LinearLayout ;

2. Add a constant and a variable to the class
private static final String AdMob_Ad_Unit = "xxxxxxxxxxxxxxx" ; private AdView adView;

3. In the onCreate method after the lines
super .loadUrl(Config.getStartUrl()) ;
add the following lines
adView = new AdView(this , AdSize.BANNER , AdMob_Ad_Unit) ; LinearLayout layout = super .root ; layout.addView(adView) ; AdRequest request = new AdRequest() ; // to run on the emulator, you can uncomment adView.loadAd(request); This is what the main project file looks like for me
import android.os.Bundle ; import org.apache.cordova.* ; import com.google.ads.* ; import android.widget.LinearLayout ; public class MyCoolApp extends DroidGap ( private static final String AdMob_Ad_Unit = "xxxxxxxxxxxxxxx" ; private AdView adView; @Override public void onCreate(Bundle savedInstanceState) ( super .onCreate (savedInstanceState) ; // Set by inconfig.xml super .loadUrl(Config.getStartUrl()) ; //super.loadUrl("file:///android_asset/www/index.html") adView = new AdView(this , AdSize.BANNER , AdMob_Ad_Unit) ; LinearLayout layout = super .root ; layout.addView(adView) ; AdRequest request = new AdRequest() ; //request.addTestDevice(AdRequest.TEST_EMULATOR); adView.loadAd(request); ) )
Add to AndroidManifest to section application following
android:name="com.google.ads.AdActivity" />
You also need to check that AndroidManifest In chapter manifest there were lines

Here's what it looks like AndroidManifest I have
android:versionCode="3" android:versionName="1.0.0" android:windowSoftInputMode="adjustPan" package="com.danilov.mycoolapp" xmlns:android= "http://schemas.android.com/apk/res/android"> android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" /> android:icon="@drawable/icon" android:label="@string/app_name" > android:configChanges= "orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/app_name" android:name="Badlibs" android:theme= "@android:style/Theme.Black.NoTitleBar"> "android.intent.category.LAUNCHER" /> android:configChanges= "keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" android:name="com.google.ads.AdActivity" /> "android.permission.ACCESS_NETWORK_STATE" />

We enter "AdMob" into Google and the first site will no longer be AdMob, but Google's site. After switching to it, you will be gradually lured to the dark side of Firebase (recently bought by Google).

Firebase provides quite extensive analytics (at least for me, as a programmer, not a marketer) of advertising in your application (height, weight, country, number of views, Android version where it was installed, etc. etc.).

First of all, a post was found, but it is for Eclipse, and after the first attempts to follow the example, warnings about depricated and, in general, errors began.

After reading more information, it became clear that the transition of AdMob to firebase happened recently and you will have to figure it out yourself.

Let's see how to live with it now

Minimum requirements: (with which the article was written).
  • Android Studio 2.2.2
  • Be registered in the Google Developer Console
  • Be registered with AdMob
Step 1
Add dependencies to build.gradle files. First thing in "Module: app":


Now in the second one ("Project: AdMobOnHabr"):


After that, it is recommended to do Tools → Android → "Sync Project with Gradle Files" and compile the project. There is no visible result yet, but the main thing is there are no mistakes? Excellent! Move on.
Step 2
Login to your AdMob account. We choose to manually add the application (if your application is already published on Google Play, use the search in the first tab).


Let's add an ad to our application banner(I suggest that you familiarize yourself with other types). Refresh rate I chose the minimum allowable - 30 sec., the name of the ad unit is up to you.


Next, you will be prompted to "Set up Firebase Analytics ( not necessary)" - underlined the right word. So far, it's useless skip. We get acquainted with the "instructions for integration", click Ready. After the redirect, we see the page and the long-awaited ID of the ad unit:


Adding ad unit ID in strings.xml:


Don't forget that an ad unit on another Activity needs a new ID.
Step 3
Add an AdView element to activity_admobbanner.xml:


In the attribute "ads:adUnitId" we write the resource from strings.xml with ad unit ID.

A few tips and notes:

Step 4
Initializing the Google Mobile Ads SDK. To do this, you will need an app ID taken from AdMob. Click gear top right → Application management:


Here it is, happiness is the desired app ID:


We write the initialization itself using our app ID:

Step 5
The last action according to Google is to load the long-awaited ad in the AdView element:


On the emulator, following the AdMob policy, you cannot display real ads (only test ads are shown). Pretty logical. But if you have a real device, you can test the ad in action on it and please yourself with success.



It seems that everything was done as written, everything should work, and it’s time for us to go to bed to work on the next feature, but ...
Step 6
Somewhere between the lines You should have read that without google-services.json it won't work. Most likely, you do not have this file yet. Let's search together.

Google kindly provides you with "sheets" of instructions on how to do google-services.json. But I had a question - do you really need to sit and write this file yourself in 2k16, which, on top of everything, is most likely rather stereotyped?

The answer is in the Google Developer Console, where they still thought about the desire of a lazy programmer.

Fill in the fields:


Click Continue. Choose Google Sing-In. Then it's simple - you know your SHA-1 by heart, don't you?


If you suddenly forgot - I can help. SHA-1 can be found using keyltool or a little clumsy - through gradle in the AS itself. Since we don’t want to do unnecessary actions, we will choose the second method:

  1. Click on the Gradle side tab (on the right in the AS window);
  2. Select your project (if necessary, click Refresh);
  3. Open Tasks -> android;
  4. Double click on signingReport;
  5. Switch to text display mode Run console (see screenshot below);
  6. Don't forget to select your application for the build later (and not signingReport);
And here is your SHA-1. Remembered?


Paste the received SHA-1 code, click "Enable Google Sign-In" and "Continue to Generate configuration files".


Well, you get the idea. Download the generated file and copy it to the root directory of the application:


Putting together your project ready. Through similar simple manipulations, your application now has ads.

P.S.: Code in pictures, so that people remember something, and not just copy-pasted in a few seconds.

There have been some changes since the release of adding AdMob ads, and today I will talk about them in more detail.
We will work not with a new project, but with an existing one, using Eclipse. Google has put together a nice tutorial on how to add ads while working in Android Studio, and I'll show you an alternative.
I will take the project from previous articles about ContentProvider, you can see the source markup files and the Activity code.
So, first we need to download (or check) the latest version of the Google Play Services package:
1. Open Android SDK Manager (Window -> Android SDK Manager)
2. Scroll down the packages window to the Extras section and see if there are updates or the latest version is installed.

Now we need to import the library from Google Play Services in order to connect it to our project later:

1. File -> Import… -> Existing Android Code into Workspace
2. The library is in the Android SDK folder: \sdk\extras\google\google_play_services\libproject\google-play-services_lib
3. Select this folder and click Finish.

It remains only to connect this library to the project:

1. Open the properties of our project: select the folder with the project in Eclipse, File -> Properties
2. In the properties window, open the Android section, and from the bottom in the Library tab, click Add ...
3. In the window that appears, select google-play-services_lib - done, the library is connected.

Now you need to set the necessary settings in the AndroidManifest.xml file.
Advertising needs the Internet and checking the current state of the network, so our application will need permissions (we specify in the tag ):

Also, for AdMob to work correctly, you must specify the version of the Google Play Services library used and define the advertising Activity (specify in the tag ):

Now let's move on to the markup file. Previously it looked like this:

And activity_main.xml will look like this:

Don't forget to include the namespace

Xmlns:ads="http://schemas.android.com/apk/res-auto"

so that an error is not generated for unknown ads: adSize and ads: adUnitId.

Ad unit ID for convenience can be added to /res/values/strings.xml in the form:

ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx

Don't forget to insert your real ad ID! You can find it on the Admob website, in the App Management section, by clicking on the inscription in the Ad units column.

@Override protected void onCreate(Bundle savedInstanceState) ( super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //.... AdView mAdView = (AdView) findViewById(R.id.adView); AdRequest adRequest = new AdRequest.Builder().build(); mAdView.loadAd(adRequest); //.... )

And run our application:

The trend to create content sites to make money on traffic began 10 years ago. The number of resources created exclusively for advertising is growing. However, you need to bet on mobile traffic. By data research company TNS, in 2017, six out of ten people accessed the Internet through mobile devices. One in four uses only mobile Internet. This is 20 million people.

The mobile advertising market in Russia is also booming. growing . In 2016, it grew by 86%, in 2017 - by 44%. By 2021, the volume should triple and reach $1 billion. Mobile advertising is divided into two channels: mobile web and mobile applications. Mobile application owners successfully monetize traffic by providing space on the screen and in the script for advertising even at the design stage.

What type of advertising to choose


    rewarded video.

    Banner.

    Rich Interstitial.

    Video Interstitial.

Reward Video- video format ads that can be viewed or skipped. As a reward for watching, users receive bonuses in the form of virtual currency, character upgrades, extra moves, and the like. The advertising format is highly engaged.

Banner(banner)- the most common form of advertising. A static horizontal banner is placed at the top or bottom. The sizes differ: at the request of Google, they should be 300x250, 728x90, 320x50 or 468x60, for advertising in Yandex - 320x100 or 320x50, additionally it can be 300x50.

Rich Interstitial- Full screen ads that can't be skipped. It only shows up for a few seconds. The usual size is 320x480. Not so long ago, a new option appeared - playable ads. This is an ad format in which the game is offered to the user.

Video Interstitial- full-screen ads in video format that can be skipped.

Appodeal Agency analyzed in 2017 the global market for advertising in mobile applications. Separately, statistics were not collected for Russia. Our country entered the region "Eastern Europe" together with 21 other countries, therefore, general data for the region are given.

According to Appodeal, Rewarded Video is the most profitable format, with an average CPM of $1.05 for Android apps and $2.33 for iOS apps.


Android


Android



Before choosing, evaluate the advantages and disadvantages of different advertising formats. Unskippable ads annoy users but generate the most revenue. Banners are the least profitable. However, they are treated loyally and do not affect the decrease in the retention rate. Also, banners are popular with advertisers due to the ease of production, so the banner advertising space will always be occupied.

How to increase the return on advertising

Study the Audience mobile application: gender, age, profession, geography. These are important indicators for advertisers, according to which sites for display will be selected. User data can be collected using services Flurry and MixPanel.

Gather dataon the number of active users, the so-called DAU, WAU and MAU. For advertisers, these metrics are more important than downloads and retention rates.

Analyze ad formats whether they are suitable for the application. For a content application, it is better to use native advertising, and for a game application, Rewarded Video. Determine if it is possible to run the selected format immediately. If, due to technical possibilities, the display of ads is delayed, do not place an application for this format. The display rate will be low: the ad has been loaded but not processed. Neither advertisers nor the ad network want this situation.

Add Rewarded Video Format for apps with purchases. It will bring additional income. For example, the Rusty Lake studio uses hints as bonuses for players when they cannot complete a level. The player watches the ad and plays on until the next dead end. This allows you to show ads to the same user many times.

Try native advertising . It is believed that it is less annoying to users. In this case, native advertising is simply disguised as regular content, i.e. advertising is native not in content, but in design. According to the Mobyaffiliates service, the share of native advertising in mobile applications is growing by 2-3% per year and by 2020 should take 63% of the total advertising volume.


Source: Mobyaffiliates.

Set a limit when showing the same ad. Set price floor - the minimum price level for advertising in your application. Additionally, limit the frequency caps - the frequency of impressions. This will reduce the intrusiveness of ads and help mitigate user annoyance.

Evaluate efficiency according to the ARPDAU metric - average revenue per daily active user. Divide the ad revenue by the number of active users. It is better to separately count different ad formats and ad impressions in different countries. When calculating, do not include December and January, because. there is a large variation in traffic during these months. In December, as a rule, the highest yield for the year, in January - the lowest.

Which ad networks to work with

The advertising network must provide partners with regular advertisers and a good income. Choose an ad network by rating. In 2017, the following networks showed the highest rates of occupancy and revenue:

Android

Reward Video

Banner

Rich Interstitial

Video Interstitial

AppLovin

AdMob

AdMob

Unity Ads

Unity Ads

MyTarget

MyTarget

AppLovin

AdColony

Yandex

Yandex

AdColony

tapjoy

Major Marketplace

Major Marketplace

Vungle

MyTarget

Inneractive Marketplace

Facebook AN

Major Marketplace

AdMob

Facebook AN

Inneractive Marketplace

InMobi

Vungle

AppLovin

startapp

Major Marketplace

Smaato

AppLovin

chartboost

InMobi

InMobi

IronSource

chartboost

Facebook AN

Smaato

iOS

Reward Video

Banner

Rich Interstitial

Video Interstitial

AppLovin

AdMob

AdMob

AppLovin

AdColony

Major Marketplace

startapp

Unity Ads

Unity Ads

Yandex

Major Marketplace

AdColony

IronSource

Inneractive Marketplace

Inneractive Marketplace

Vungle

tapjoy

MyTarget

Yandex

Major Marketplace

Vungle

AppLovin

AppLovin

InMobi

AdMob

Facebook AN

MyTarget

Facebook AN

InMobi

Facebook AN

chartboost

IronSource

Major Marketplace

InMobi

MyTarget

chartboost

The format of work is different. You can work with the advertising network directly or through intermediaries:

    SSP (Sell Side Platform) - technological platforms for the sale of advertising space;

    Ad Mediation - advertising optimization services to work with many advertising networks.

How to work with ad networks

    You can't force users to click on ads. No CTA messages and plaintive inscriptions in the format “Advertising helps us provide our services for free.”

    • after each button press or transition;

      when the application is minimized;

      when launching a mobile application;

      when returning from sleep mode;

      on the login, logout, thank you, error, and similar screens;

      several times in a row, one after the other.

    • do not place multiple banners on the screen.

Remember

    The share of mobile Internet users is growing. In 2017, 54% of users in Russia accessed the Internet via smartphones at least once a month, 24% use only mobile Internet. The volume of the Russian mobile advertising market in 2016 amounted to $309 million. By 2021, the volume should grow to $1 billion.

    The main advertising formats in mobile apps are: Rewarded Video, Banner, Rich Interstitial and Video Interstitial. They differ in demand among advertisers, in the degree of user annoyance and in income. The highest average CPM comes from Rewarded Video.

    Collect statistics on the audience of the application and provide data on the socio-demographic characteristics of users and geography. Indicate indicators for the active audience DAU, WAU, MAU. Choose ad formats for the type of application. Try suitable formats, evaluate using the ARPDAU metric. Set a limit on the frequency of impressions and a minimum price threshold.

Loading...Loading...