Getting started with admob for android - confused about documentation

I was just starting to learn about Admob ad placement in the Android application that I am creating. Nothing good so far. I followed the example in AdMod_Android_SDK_Instructions.pdf, which I downloaded from the adMob website, but I'm confused. On page 7, I see the import statements refer to the package as com.admob.android.ads - but in the SDK that I downloaded, is the com.google.ads package the rest of it before Google acquired admob? Then it is called by a dView.requestFreshAd(); - which does not exist in the last code. Please can someone help me with code that really works? My specific errors from logcat:

AdView does not have the required XML attribute adUnitId.

... then after the call adView.loadAd(new AdRequest()); I get:

Invalid unknown request error: Cannot determine request type.  Is your ad unit Id correct?
onFailedToReceiveAd(Invalid Google Ad request).

Any help greatly appreciated! Thank.

+3
source share
4 answers

Starting from 4.1.0,

mob1lejunkie is absolutely right you can remove

  • attrs.xml
  • primarytextcolor, secondarytextcolor attributes (and define them on the admob website on the Settings Management tab of your application)
  • remove the xmlns: myapp namespace from the main layout in your XML file and replace it with xmlns: ads (note here! The new xmlns is not in / apk / res, but apk / lib)
  • change adUnitID and adSize namespace in adView xml snippet

so here is the working xml snippet with admob 4.1.0:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="fill_parent"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads">

    <com.google.ads.AdView android:id="@+id/ad"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        ads:adUnitId="a14d7f7d2180609"
        ads:adSize="BANNER" />
</RelativeLayout>

Google, librairy, Google? adwhirl...

, , , Google attrs.xml. admob android.

, , , admob id strings.xml : http://groups.google.com/group/google-admob-ads-sdk/browse_thread/thread/c57917b4491a0c1

xml :

ads:adUnitId="@string/admob_unit_id"

<string name="admob_unit_id">a14d7f7d2180609</string>

strings.xml . admob .

.

,  

+12

4.1.0, , Admob ( 15 ) .

attrs.xml ,

xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads

rater,

xmlns:ads="http://schemas.android.com/apk/res/com.your.packagename
+2
+1

All Articles