Android Question new admob integration

merlin2049er

Well-Known Member
Licensed User
Longtime User
Hi, I signed up for an admob account. Got an ap-id after creating a top banner.

I then proceeded to update android sdk, and eclipse plugin. Then downloaded the admob 1.40 library, and downloaded the GoogleAdMobAdsSdk-6.4.1.jar (renamed this to GoogleAdMobAdsSdk.jar) and copied them both to basic4android/Additional libraries...

I used NJdude's code (thanks!)

B4X:
 Adbox.Initialize2("Ad", "xxxxx", Adbox.SIZE_BANNER)
    Activity.AddView(Adbox, 0dip, Activity.Height - 50dip, Adbox.Width, Adbox.Height)
    Adbox.LoadAd
         
    ToastMessageShow("Width=" & Adbox.Width, True)
    ToastMessageShow("Height=" & Adbox.Height, True)

substituted "xxxx" with my ap-id.

It compiles alright, but I get stuck on as it starts up.

B4X:
 Activity.AddView(Adbox, 0dip, Activity.Height - 50dip, Adbox.Width, Adbox.Height)


I get a java.lang.NullPointerException.
 

NJDude

Expert
Licensed User
Longtime User
Do you have these lines in the Manifest?
B4X:
AddApplicationText(<!-- *** For AdMob: manually added *** -->)
AddApplicationText(<activity android:name="com.google.ads.AdActivity")
AddApplicationText(android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|smallestScreenSize|screenSize"/>)

However, not having these lines should display a different error message.
 
Upvote 0

merlin2049er

Well-Known Member
Licensed User
Longtime User
Ok, just added that to the manifest, but it didn't help.

Just noticed under my global area troubleshooting section...

Adbox (adview) Layout not available.

Do I have to create another layout in the designer? (for the add)
 
Upvote 0

NJDude

Expert
Licensed User
Longtime User
You have to replace line #119

From:
B4X:
Activity.AddView(Adbox, 0dip, Activity.Height - 50dip, Adbox.Width, Adbox.Height)
To:
B4X:
Activity.AddView(AdBox, 0dip, 100%y - 50dip, 100%x, 50dip)
 
Upvote 0
Top