Adwhirl with Admob java.lang.NosuchMethodError:com.google.ads.AdView.destroy - android

i'm using adwhirl with admob..The ads appears but i'm getting this exception in the log
java.lang.NosuchMethodError:com.google.ads.AdView.destroy
i don't understand why ..
i'm using adwhirl layout in my activites to request the ads..
LinearLayout adLayout = (LinearLayout) findViewById(R.id.ads);
AdWhirlLayout adWhirlLayout = new AdWhirlLayout(this, "---------");
RelativeLayout.LayoutParams adWhirlLayoutParams = new
RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT);
adLayout.addView(adWhirlLayout, adWhirlLayoutParams);
adLayout.invalidate();
and i'm just using the SDKs for the other AdNw ,declaring them in the manifest
is it the right way to request Ads ???

The AdMob Adapter will call the destroy method when it is being destroyed. That method should be exist if you have the AdMob SDK included in your app. Make sure that you have the most recent version (4.3.1) of the Google AdMob SDK and that you have included it in your app.
Also, is this how you declared the AdActivity for AdMob in the manifest?
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
Finally, I don't know if it is related to this issue, but you defined some RelativeLayout params but you are adding it to a LinearLayout. You don't really need to specify those params at all. This should suffice:
LinearLayout adLayout = (LinearLayout) findViewById(R.id.ads);
AdWhirlLayout adWhirlLayout = new AdWhirlLayout(this, "YOUR_ADWHIRL_KEY_GOES_HERE");
adLayout.addView(adWhirlLayout);

Related

AdMob Banner is shown behind a View?

Hi I am using AdMoB for showing banner ad in YouTube app which retrieves Video From Channel . For showing ad I used Java Code rather than XML. Now I am facing one problem which is my Banner is shown behind the Videos after the gets loaded. Can someone please help me to find out a way to show the ad front of the Videos. This is the code i used
adView = new AdView(this, AdSize.BANNER, "caXXXXXXXXXXXX");
FrameLayout layout = (FrameLayout)findViewById(R.id.content_frame);
layout.addView(adView);
#SuppressWarnings("deprecation")
FrameLayout.LayoutParams adsParams = new FrameLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT);
adView.loadAd(new AdRequest());
Try this way.
This is the xml code of the banner, you can place it wherever you want in your activity xml layout:
<com.google.ads.AdView android:id="#+id/banner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId="YOUR UNIT ID HERE"
ads:adSize="BANNER"
ads:loadAdsOnCreate="true"/>
Then inside <application> tag in AndroidManifest.xml declare the AdActivity:
<activity
android:name="com.google.ads.AdActivity"
android:label="#string/app_name" >
And finnaly get the reference on your activity of banner and start request ads from google:
AdView ad = (AdView) findViewById(R.id.banner);
ad.loadAd(new AdRequest());
What layout are you using? To get ads on top of my Libgdx projects, I had to use a RelativeLayout and specify put things together in a specific order. Here's an example from my code:
// Create the main/content layout
RelativeLayout layout = new RelativeLayout(this);
// This is just a View that LibGDX draws into, it could be any View.
View gameView = initializeForView(new SuperAwesomeGameIMade(AndroidLauncher.this));
// Add it to the new content layout.
layout.addView(gameView);
// Create and setup the AdMob View
mAdView = new AdView(AndroidLauncher.this);
mAdView.setAdSize(AdSize.SMART_BANNER);
mAdView.setAdUnitId("your ad unit here");
// Create the ad load request using the AdRequest Builder
AdRequest.Builder adRequestBuilder = new AdRequest.Builder();
adRequestBuilder.addTestDevice("your test device ID so you don't get banned!");
mAdView.setVisibility(View.GONE); // Change to View.Visible to show ads
mAdView.loadAd(adRequestBuilder.build());
// Setup the AdView with new layout params so it can "float" on the other one.
RelativeLayout.LayoutParams adParams =
new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
adParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
adParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
layout.addView(mAdView, adParams);
// Set the content view as this new relative layout
setContentView(layout);
Hope that gets you pointed in the right direction.

Set Height for AdView banner on latest Admob version

I am using latest admob version (https://developers.google.com/mobile-ads-sdk/docs/admob/fundamentals - the Google Play version) for my application. i wanna set height for my AdView banners (BANNER and SMART_BANNER in AdSize). But i can find out any methods or any ways to set it. I have followed exactly the guide from google admob site.
Thank you.
New edit :
This is my implementation :
adView = new AdView(m_context);
adView.setAdSize(AdSize.SMART_BANNER);
adView.setAdUnitId(m_context.getString(R.string.admob_id));
LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT);
wrapper.addView(adView, param);
adView.setAdSize(AdSize.BANNER);
See https://developers.google.com/mobile-ads-sdk/docs/admob/fundamentals

Admob is never shown

I'm trying to display an Admob ad but it's never shown. This is so weird.
This is my implementation:
Manifest:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
XML:
<RelativeLayout
android:id="#+id/containerGlobal"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#C7CFD9"/>
And the code:
ViewGroup holder = (ViewGroup) findViewById(R.id.containerGlobal);
AdView adView = new AdView( this, AdSize.BANNER, "adunit..." );
holder.addView(adView);
AdRequest adRequest = new AdRequest();
adRequest.addTestDevice(AdRequest.TEST_EMULATOR);
adRequest.addTestDevice("5A33BC58556417FFF74F329CDFA95B7E");
adRequest.addTestDevice("8DAC38F2726F4802D60BF7EBA8A5FC39");
adView.loadAd( adRequest );
Logcat:
Any tips?
Edit
This is my code now:
And logcat output... Looks like everything is working, but nothing is shown...
**Edit 2 **
Several hours later, still have the issue.
When you initialise your AdView, try doing the following after it:
AdView adView = new AdView(this, AdSize.BANNER, "adUnitId");
adView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
LayoutParams params = (LayoutParams)adView .getLayoutParams();
params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
params.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
adView.setLayoutParams(params);
holder.addView(adView);
To set the height/width of the add, and then it's position at the bottom-centre of the screen.
Ok... Finally solved. it was all related with my layouts. I don't really know what was the issue, just removed some of them, changed params of them, and it's being shown now.
Thank you everyone.
instead of "adunit..." place there your real publisher ID that can be found on admob page

Can we use GoogleAds/AdMob/AdWhirl in cocos2d-android?

I want to add the Admob / AdWhirl into the GameLayer Scene.
I search over everywhere but couldn't find the way to do this work. I don't want to switch the Library. So , what should i do?
If someone have worked on it , give some way to do this .
as there is not layout xml file for cocos2d android you can add it progammatically. crate linear layout in onstart method itself.
like this
LinearLayout.LayoutParams adParams = new LinearLayout.LayoutParams(
getWindowManager().getDefaultDisplay().getWidth(),
getWindowManager().getDefaultDisplay().getHeight()+getWindowManager().getDefaultDisplay().getHeight()-50);
adView = new AdView(SimpleGame.this, AdSize.BANNER, "your Ad ID");
adView.setAdListener(SimpleGame.this);
AdRequest request = new AdRequest();
request.addTestDevice(AdRequest.TEST_EMULATOR);
adView.loadAd(request);
CCDirector.sharedDirector().getActivity().addContentView(adView,adParams);
this should be in try and catch.
of course we can add admob and or any other lib in your cocos2d games activity class.
You need to implement adlistener to your activity and add the adview in the OnStart() method of your game .

How to integrate Inmobi with Adwhirl and Admob in android

I already used admob 4.3.1 with ad-whirl in my android application...but i want to use Inmobi too...but I don't know if i must change something in my code...i read that inmobi reqiure Adwhirl 3.0.0 sdk...but i'm using 3.1.1 with admob...
any help please...
i put the 3 SDKs...used the needed Permissions,,
Declaring these two activites:
<activity android:name="com.google.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation"/>
<!-- Mandatory activity declaration to show the Ad in the embedded browser -->
<activity android:name="com.inmobi.androidsdk.IMBrowserActivity"
android:configChanges="keyboardHidden|orientation|keyboard" />
and this in my activity:
LinearLayout adLayout = (LinearLayout) findViewById(R.id.ads);
AdWhirlLayout adWhirlLayout = new AdWhirlLayout(this, "Key");
RelativeLayout.LayoutParams adWhirlLayoutParams = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT);
adLayout.addView(adWhirlLayout, adWhirlLayoutParams);
If you look at the AdWhirl change log, you can see that AdWhirl 3.1.1 has support for the latest InMobi SDK, which is currently v300. If you have AdWhirl 3.1.1, make sure you're using the latest InMobi SDK.
On another note, if you are using AdMob 4.3.1, you'll need to update your activity declaration to:
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
If you are having issues with the above code, please check out this blog post for more information on how to migrate to v4.3.1 of the AdMob SDK. This information is just as relevant if you are using AdMob with AdWhirl.
Your Java code which defines your layout is correct, assuming you are using the right app key. Nothing else should be needed to get InMobi working other than their latest SDK.

Categories

Resources