2

I have a strange problem with integrating AdWhirl into my android app.

Networks connected through AdWhirl:
* Mileniall Media
* AdMob
* InMobi (it gives invalid adapter error but thats a known issue and not the main problem)

I've downoaded and included AdWhirl SDK 3.0.0, the jars for respective network and did all the steps included in the manual (changes in manifest file, lib including etc)

And I've put the AdWhirl code into my app.

Layout that is the placeholder for AdWhirlLayout.

<LinearLayout
        android:id="@+id/ads"
        android:layout_width="fill_parent"
        android:layout_height="52dip"
        android:layout_weight="0"
        android:background="#0f0"/>

Code for ads layout:

adLayout = (LinearLayout) findViewById(R.id.ads);
AdWhirlLayout adWhirlLayout = new AdWhirlLayout(this, "ad whirl code");
RelativeLayout.LayoutParams adWhirlLayoutParams = new RelativeLayout.LayoutParams(UIUtils.dip(320), UIUtils.dip(52));
adWhirlLayout.setBackgroundColor(Color.DKGRAY);
adLayout.addView(adWhirlLayout, adWhirlLayoutParams);
adLayout.invalidate();

I can see that both of the layouts are shown (due to the color that they have).

I also know that the networks are connected correctly because I can see that in logcat

05-11 15:11:52.279: DEBUG/AdWhirl SDK(8013): Showing ad:
05-11 15:11:52.279: DEBUG/AdWhirl SDK(8013):     nid: d10c4fe5e08f469ca1992bfe277902f5
05-11 15:11:52.279: DEBUG/AdWhirl SDK(8013):     name: millennial
05-11 15:11:52.279: DEBUG/AdWhirl SDK(8013):     type: 6
05-11 15:11:52.279: DEBUG/AdWhirl SDK(8013):     key: XXXXX
05-11 15:11:52.279: DEBUG/AdWhirl SDK(8013):     key2: 
05-11 15:11:52.279: DEBUG/AdWhirl SDK(8013): Valid adapter, calling handle()

and on the network sites - I see the ad request there.

But the layout stays gray, no matter what. I'm puzzled.

darkhie
  • 263
  • 1
  • 15

1 Answers1

1

The documentation for AdWhirl is pretty horrible. Try this much simpler way to inflate the AdWhirl layout:

Instead of creating the layout through code you can simply create it through your normal XML layout file. Don't use the LinearLayout like their instructions suggest (I think it's outdated). Instead just place this element in your layout wherever you want the banner to be:

    <com.adwhirl.AdWhirlLayout
         android:layout_width="fill_parent"
         android:layout_height="wrap_content" />

Seriously, that's it. Be sure your AdWhirl key is in the Manifest as well (either within the <activity> or <application> tag):

    <meta-data android:value="Your Key"
         android:name="ADWHIRL_KEY"/>

If you really need to do anything programmatically you can give the layout an id as usual and use findViewById. Lemme know if this helps.

Tony Chan
  • 8,017
  • 4
  • 50
  • 49
  • Isn't this leaving yourself open to problems from AdWhirl a bit? If you use wrap_content, and they serve you an incorrectly-sized ad, your app has problems. (And yes, that would be a bug on the side of the ad network, but at least there are ways to adjust how much pain that causes your ap). – James Moore Aug 07 '11 at 00:04
  • @James Yeah, there's something of a conflict because Android's "best practices" suggests that you try not to hard code dimensions in. I think AdWhirl instructions do recommend setting height to 50px (or equivalent in dp). And in fact there is an ad network, MdotM, that has this exact bug that you mention. The problem with hardcoding in the dimensions is that you'll be left with a blank box in your UI if there is no ads. There's a way around this using their poorly documented setMaxHeight() method, but I left it out for simplicity. I should probably edit my answer – Tony Chan Aug 08 '11 at 20:22