Tag Archives: android

Errors and Issues Found While Adding AdMob for Android

On my to do list for a while was to add advertisements to my application, CountView. I’m not really interested in making a profit in any way but I wanted to see how hard it was to do and if you could expect any kind of profit at all. If I’m ever going to make a career of this app and custom development career then it’s best to
start small and work up from there.

Given how common ad platforms are I was expecting that adding them to my app was going to be very straight forward. And in some ways it was. The first choice was between AdSense and AdMob, both provided by Google. Google makes it quite clear that they believe AdMob is the platform of choice for Android apps and apps in general. There’s definitely nothing stopping you using AdSense and importing it into a web container but I have to agree that the concept behind AdMob makes sense.

AdMob recently released a new version 4.3.1 that I think came out in October 2011. My first issue was that you needed at least Android 3.2 (the tablet version) to compile it against and for some reason that refused to deploy to my Nexus One running 2.3.3 even though it was supposed to be backward compatible to Android 1.5. I got round most of this by installing the Ice Cream Sandwich Emulator which seemed a lot better than the earlier versions that I had use previously. The even better fix for this was that I bought a Galaxy Nexus. All problems solved!

Then the real problems started. I deployed it and the ad just refused to show. No errors. It said that an ad was being received and then nothing. Added some house ads and still nothing. Added my device multiple ways as a test device and still no luck. Had me stumped for ages. Eventually I found the following errors:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.fozziewossie.android/com.fozziewossie.android.CountViewActivity}: java.lang.ClassCastException: com.google.ads.AdView cannot be cast to android.widget.TextView

Caused by: java.lang.ClassCastException: com.google.ads.AdView cannot be cast to android.widget.TextView

And I was like, what the? All I was doing at that line was:

TextView countTextView = (TextView) findViewById(R.id.CountField);

That made no sense at all to me. I did some extensive Googling and none of it seemed to help. Eventually I just did my standard response when things refused to work and just fecked around.

My solution. Wrap the com.google.ads.AdView component in the XML in a Linear Layout and move it to the top of the application. Why that fixes it I have no idea. I’m results driven, it works!

The new version of CountView is being released tonight and includes one other change to have the background colour default to black with white text. It’s much more sophisticated.

CountView – Part 3 – CountView on the Android Market

CountView has now reached the pinnacle that an Android application can reach – it’s made it to the Android Marketplace! Okay, well, that might not quite be the pinnacle. Angry Birds has probably taken that with the number of downloads and popular references. Getting on the market is still pretty cool though even if it cost me
US$25 to get a developer account.

So there’s new steps now and it’s not much easier really although they are a little more standard since nearly everyone has installed an app from the market.


  1. Open the market
  2. Press the search button
  3. Type in CountView
  4. Press Enter
  5. Click on the CountView application
  6. Select Install
  7. Select the very minimal permissions
  8. Done!

And how’s the app doing? I’ve had fourteen people install it and nine are still using it. Here’s my favourite graph that Google provides:

Active installs of CounView by country

CountView – Part 2

I’ve finally convinced some people (poor suckers!) that my app has some relevance and they are keen to install it. Unfortunately the first person I tried to help install CountView it ran into a big fat error that I had never seen before. So, one day later I’ve actually tested the install myself (which I probably should have done in the first place) and I can now give you the full instructions on how to download and install the application.

1. Allow unknown source (ie. other than the Android Market to be installed):
First step is to let installation happen straight from your SD card. To do this from your home screen click then options/settings button, select Settings, select Applications and tick the Unknown sources check box accepting any warnings that it gives. You can uncheck this after you finish installing if you’re worried about security.

2. Download the CountView installer:
The installer is called AndroidCountViews.apk
and you’ll need to get this onto your phone so that it can be installed. The easiest way to do this is to probably open up your browser in your phone and find this blog page, click the link:  AndroidCountViews.apk
and whallah! you’re done. Downloaded and ready for install. If that’s no good then you can download it to your PC and transfer it using the USB cord.

3. Download a file manager application:
I’ve tried a couple of these and they’ve both seemed good. First on the list is Adao File Manager. The second is Android File Manager. You can find both of them on the market – just search by name.

4. Install the application:
Now that you’ve installed your file manager you’ll be able to install the CountView APK. To do this open up your file manager of choice, navigate to the Download (could be in lower case – download) folder. This is where all your downloaded files from your browser go. Then just click on the AndroidCountViews.apk file that we downloaded in step 1, and install it. You can then open the application up and away you go.

You might want to add the icon do your desktop area so you can quickly retrieve it and see your stats but that’s about it. The application will launch itself if you ever restart your phone and it should just sit away in the background checking when ever your screen comes on.

If you still find these steps a bit confronting and you don’t want to help me beta test the application, then hold on a bit longer while I work on getting my Android Market page up. Aim is to have it up and running by the end of June. And here’s some screen shots that you’ll be seeing shortly:

Application in motionIcon on my desktop

Edit: You can now get this off the Android Play store.

CountView – Part 1

Long time between posts but never fear, I have been busy! My latest project is called CountView and it’s my second substantial android project. The idea came from a random article I read that gave some figures on how often people look at their mobile phone. I’ve spent some time looking for the initial research with no luck but as far as I know it was done by Nokia, found that people look at their phones on average once every 6.5 minutes and up to 150 times a day. If you now of the actual study then please let me know as I’d love a read.

CountView is my effort to reproduce and verify that study. It’s a fairly simple app that keeps track of how many times you look at your phone each day. At the moment it’s not recording the time, just the number per day. This is then used to provide a count per week and a total count of views and how many days you’ve used your phone.

The application is definitely a work in progress at the moment. I’ve got it up to a point where I’m happy to share it but there’s definitely a lot more to be done before I move it to the android market. Those things include

  • Being able to submit your usage data
  • Being able to set your age and sex and submit that to
  • Making it look a bit nicer, and
  • Figuring out the rest of the Android market place process

So, you’d like to try it? You can download the APK and give it a shot.

Hopefully it will self install and you’ll be hot to trot. All feedback appreciated!