Implementing mobfox and admob in the same app

1.5k Views Asked by At

I have an application with MobFox and AdMob. If the MobFox ads are not showing, the AdMob ads appear. I have recently upgraded the android sdk to 20 and apart from the many many errors and the slowed down eclipse, mobfox showed me a lot of errors. I upgraded the mobfox sdk and changed the code to show the mobfox ads. Then I wanted to make the admob ads work but I keep getting errors. I updated it to newest sdk, 6.1.0. The problem is, both MobFox and AdMob uses AdView.

If I add import com.adsdk.sdk.banner.AdView; MobFox ads work but I get errors in the AdMob code. If I add import com.google.ads.AdView; Admob ads work but I get errors in the MobFox code:

The import com.google.ads.AdView collides with another import statement

AdMob error example when importing only the relevant MobFox AdView:

The method loadAd(AdRequest) is undefined for the type AdView

  AdView ad = (AdView)findViewById(R.id.admobContent);
  ad.loadAd(new AdRequest()); //error

I import com.google.ads.*; in vain, since it doesn't recognizes the admob AdView:

The constructor AdView(MainActivity, AdSize, String) is undefined

Because of this import error I cannot implement both ad networks in my app. Any ideas?

1

There are 1 best solutions below

0
On

Are you using AdMob Mediation? If so, you just pop in the MobFox SDK and adapter, and you don't have to write any of the code yourself.

If you aren't using a mediation solution (I would recommend one btw), you can avoid this issue by removing on the of the imports, and referencing the class by it's fully qualified class. For example:

com.google.ads.AdView ad = (com.google.ads.AdView)findViewById(R.id.admobContent);

Then you won't need to import com.google.ads.AdView.