0

i want to integrate admob code inside my test app, here are the steps i have followed.

Layout file looks like this

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:gravity="bottom"
        android:id="@+id/layout_ad">

</LinearLayout>

Manifest file looks like this

<?xml version="1.0" encoding="utf-8"?>

<uses-sdk android:minSdkVersion="8" />
    <uses-permission android:name="android.permission.INTERNET" />

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >
    <activity
        android:name=".Dummyads2Activity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

And finally here how the code looks

public class Dummyads2Activity extends Activity {//implements AdWhirlInterface{
/** Called when the activity is first created. */

private AdWhirlLayout adWhirlLayout;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);


   try{
        AdManager.setTestDevices( new String[] { AdManager.TEST_EMULATOR } );
        LinearLayout layout = (LinearLayout)findViewById(R.id.layout_ad);
        AdWhirlLayout adWhirlLayout = new AdWhirlLayout(this, "my adwhirl id");
        Display d = this.getWindowManager().getDefaultDisplay();
        RelativeLayout.LayoutParams adWhirlLayoutParams = new RelativeLayout.LayoutParams(d.getWidth(), 72);
        layout.addView(adWhirlLayout, adWhirlLayoutParams);
    }catch(Exception e){
        //Log.e(TAG, "Unable to create AdWhirlLayout", e);
    }

}

If i do like this, my app crashes, and no ads appear. Kindly help me in solving the problem.

Eric Leichtenschlag
  • 8,881
  • 1
  • 28
  • 28
Naruto
  • 9,476
  • 37
  • 118
  • 201
  • Excuse me for my ignorance if I'm mistaken, but I see no reason for this to be tagged C++. – Drise Jul 24 '12 at 15:25

1 Answers1

0

This really depends on what versions of AdMob and AdWhirl you're using. I'm going to talk about AdMob SDK v6.1.0 and AdWhirl v3.2.0, which are currently the newest versions.

You're probably crashing because of this line:

AdManager.setTestDevices( new String[] { AdManager.TEST_EMULATOR } );

This looks like legacy AdMob AdManager; AdWhirl uses the Google AdMob SDK. Anyhow, if you want test ads with AdWhirl, you want to set testing through AdWhirl, not through an ad network. So remove the above line and set test mode like this:

AdWhirlTargeting.setTestMode(true);

Also, your manifest will need to have a superset of all the permissions and activity definitions of the networks you're mediating with. For AdMob, you'll need to add:

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
...
<activity android:name="com.google.ads.AdActivity"
              android:configChanges="orientation|keyboard|keyboardHidden|screenLayout|uiMode|screenSize|smallestScreenSize" />

If you still run into errors, posting some logging output would be useful. If you're using Eclipse, you can find logcat from Window -> Show View -> Other... -> Android -> LogCat. Or you can get the logcat output from the command line using adb logcat with Android's adb tool.

Eric Leichtenschlag
  • 8,881
  • 1
  • 28
  • 28