Add Advertisements To Your Android Apps

Gadgets Category

Add Advertisements To Your Android Apps

This will help the developers to make money using advertisements. From this you can understand to use the AdMob to add advertisements in Android Applications

  • Create an AdMob account
  • Once your AdMob account is created, Login using your account.
  • Click on sites & Apps tab on the top menu. Then click on Add Site/App button to add the application you want your advertisements to show up on.
  • Select the platform your created application is, in this case select Android.
  • Enter the required details to add an app to the list. You should already know the application name and the package name for your application. Therefore write the name of your application in the app name field, and write the android package URL as market://details?id=<Package name>. Enter your package name by replacing the <Package name >. For category select what type of app your application is, and write a small description in the description box to tell what type of app it is. There is also an option to include Google ads, which can be useful to get ad fills when AdMob ads are not displayed.
  • Once you hit continue, AdMob will add your application to the list and ask you to download the AdMob Android SDK. Click on the download button to download the SDK.
  • While AdMob SDK is downloading, click on the go to Sites/Apps button to return to your list applications, then click on manage settings on the listed app to find your publisher ID.
  • Extract the downloaded .Zip file with the AdMob Android SDK to an easily accessible location.
  • Now start your Eclipse IDE to import the downloaded SDK. Find the folder containing your Android application and right click to choose properties option.
  • Select Java Build Path option from the navigation plan to your left and then click on libraries tab to add the SDK file. Click on Add external JARS button and locate the unzipped AdMob SDK JAR file on your disk, and add it to your project.
  • If you successfully completed the previous step, you should now see the JAR file located under, Referenced Libraries folder inside your project.
  • Once the SDK is added to your project, open the AndroidManifest.xml file located in your project. In order to use AdMob in your application you must include the following xml Just before the </application> tag enter a new activity for com.google.ads.AdActivity by adding this xml.<activity android:name=”com.google.ads.AdActivity” android:configChanges=”keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize” />
  • After the </application> tag enter permissions that are required by AdMob.<uses-sdk android:minSdkVersion=”7″ /> <uses-permission android:name=”android.permission.INTERNET” /> <uses-permission android:name=”android.permission.ACCESS_NETWORK_STATE” />
  • Open the project.properties file in your Android application folder and change this line of code at the end of the file to make AdMob SDK work. AdMob SDK requires android SDK-13, and since our application was SDK-7 we require changing the target version, target=android-13.
  • Finally, to add an AdMob advertisement to your application, open your desired layout xml file. For this tutorial we will just add it to our main.xml located under res/layout folder of our project. Then add this following xml where you like to show your ad in your layout.In <LinearLayout> tag add xmlns:ads= “http://schemas.android.com/apk/lib/com.google.ads” After the <LinearLayout> tag add <com.google.ads.AdView android:id=”@+id/adView” android:layout_width=”wrap_content” android:layout_height=”wrap_content” ads:adSize=”BANNER” ads:adUnitId=”YOUR PUBLISHER ID” ads:loadAdOnCreate=”true” > </com.google.ads.AdView>
  • Run your application and give it up to 5 minutes on initial run to have AdMob ads show on your application.

Note

Make sure you put your own publisher ID, otherwise you will not get paid.

Amarnath Natarajan Avatar

Help Us Grow

If you like this post, please share it with your friends.

You are free to copy and redistribute this article in any medium or format, as long as you keep the links in the article or provide a link back to this page.

Subscribe to Newsletter




Privacy Settings

Privacy & Cookie Overview

Our website uses cookies to provide you with the best user experience possible. These cookies are stored in your browser and perform essential functions such as recognizing you when you return to our website, as well as helping us to understand which sections of the website you find most useful and engaging.

To learn more, you can read our Privacy & Cookie Policy or reach out through our Contact form.

Strictly Necessary Cookies

Strictly Necessary Cookies must always be enabled to ensure the proper functioning of this website and to allow us to provide you with excellent service. These cookies are also essential for saving your cookie preferences.

Google Adsense

We use Google AdSense to keep this site free by displaying relevant ads. AdSense requires essential cookies that cannot be disabled, but you can manage other cookies. We respect your privacy and provide options to control non-essential cookies.

For more details on how Google handles your data, visit Google's Data Usage Policy. Please review our Privacy Policy for more information on how we protect your data.

AddToAny

We use AddToAny for social sharing. It doesn’t store cookies, ensuring a privacy-friendly experience. AddToAny complies with GDPR and CCPA by default.

For more, see their Privacy Policy.

OneSignal

We use OneSignal to send notifications to users who opt in. OneSignal complies with GDPR and is certified under the EU-US and Swiss-US Privacy Shield frameworks.

For more, see their Privacy Policy.

3rd Party Cookies

This website utilizes third-party cookies, which can enhance your experience and support our ongoing efforts to improve our services.

Google Analytics

We use Google Analytics to collect anonymous data, such as visitor numbers and popular pages, to improve user experience and site performance. Keeping this cookie enabled helps us refine the site based on visitor activity.

For more information, see Google’s Privacy Policy.

Discover more from Prime Inspiration

Subscribe now to keep reading and get access to the full archive.

Continue reading