Android app development and making Admob ads display

My brain is so full of Android app development that I don’t even know where to start.  Here are a few small tidbits though:

Give Admob ads enough space
Admob ads won’t display if you don’t give them enough room.  Specifically, 320dp x 48dp (dp = dip = density independent pixels).  It won’t actually tell you that the ad won’t display – the debugger log will show that an ad was retrieved, but nothing shows up on the screen.  Mobclix ads will show up in that space, but Admob ones won’t.

The problem was that I was squeezing the ad into half of the landscape screen.  An ad comfortably fits across the top in portrait mode, but seems to be wasting space in landscape mode.  I used the attribute android:layout_weight=”1″ for each of two columns and figured I had a clever solution to maximize space.  Once I found the reference to the 320dp width requirement I recalculated — on my Motorola Droid the screen is 848 x 480.  A little more obscure, at that resolution the ration of pixels to dp is 1.5:1.  So, while I was giving 424px to the ad, it was only counted as 282dp.  Hence, no display.

Maybe Admob mentioned this somewhere and I missed it.  Either way, I updated my layout to ensure that Admob ads get enough space, and display works.

Rotate the screen
Another thing I had to search on. To rotate emulator, turn numlock of then press 7 or 9 to rotate to landscape and back.  Now I can easily test how my app handles a rotation configuration change!

Posted in Android permalink

About ProjectJourneyman

I am a software engineer that escaped the cubicle world at a large company to go solo with Android app development. My attention to detail and quality applies both to my apps and to my research on how to make money with Android. Now that I have the freedom to work on my own projects, I am documenting my efforts in the hopes that it will help other current or aspiring independent Android developers get the income they desire.

Comments are closed.