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.
Related
I am integrating Inmobi SDK for ads in my android application. I have setup my inmobi account and have the application id from there. Below is the XML is use to setup the ad
<com.inmobi.monetization.IMBanner
android:layout_width="320dp"
android:layout_height="50dp"
android:id="#+id/banner"
adSize="15"
appId="xxxxxxxxxx"
/>
And of course i have replaced the XXXXX with my application id from the property in my Inmobi account. The first problem i observed was that appId is not being identified as a valid attribute.
Secondly if i try and do a findViewById in my activity I always get a null reference back.
What am i missing in the implementation here?
This was a very silly mistake. In Android Studio there were multiple layout files for the same activity and I was adding the AdView only to one of them.
My application was working with android 4.2 and using Admob x.x.x.jar file few days back.
i just configured android sdk 4.4 and i noticed Google play ads are not longer working, also found it should be upgraded as well so what i did following:
Before My XML Was:
<com.google.android.gms.ads.AdView
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_gravity="center"
ads:adSize="BANNER"
ads:adUnitId="asdadadasddas"
/>
Today I updated it
<com.google.android.gms.ads.AdView android:id="#+id/adView"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="match_parent"
android:layout_height="wrap_content"
ads:adUnitId="asdadadasddas"
ads:adSize="BANNER"
/>
My Manifest
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version"/>
values => Integer.xml
<integer name="google_play_services_version">5089034</integer>
and it give me following error
Note: I am not using any java code to display it is that necessary?
any help would be appreciated.
I appreciate answers of all developers actually i solved this problem by combining the answers of all so i would like to enter steps here that might help others.
XML Layout:
<com.google.android.gms.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="#+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
ads:adUnitId="ca-app-pub-***"
ads:adSize="BANNER"
/>
Two mistakes in my code were:
1) xmlns:ads value was wrong & this mistake pointed out by donfuxx
2) i was using old AdUnitId with following format: a15220c7a5f3775 but in latest AdMob its format is entirely different as used in above example.
Note:
If you use old "ads:adUnitId" it will show blank ad and this was the case with me.
Javacode
Java code is also required
AdRequest adRequest = new AdRequest.Builder()
.build();
AdView adView = (AdView) view.findViewById(R.id.adView);
adView.loadAd(adRequest);
Then again i found another error:
Class not found exception although i had imported the Google Play project in my application.
Then i found an article in which it was mentioned copy Google Play Jar inside your "libs" folder and it will be automatically included in your android private libraries to resolve this issue.
Final Issue
No need to put value in integer.xml inside your app because when you include Google play services project inside your app, it will automatically pick version value out of it in your manifest file.
So these were the issues i faced during migration of adMob and will help others to implement it quickly.
You can still use ads:adSize xml attribute!
However, your xml namespace setting is wrong in the adview element, because it refers to the legacy admob:
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
but since you already use the google play admob, you should use:
xmlns:ads="http://schemas.android.com/apk/res-auto"
that is why the ads: attributes were not recognized.
More infos see the official admob migration guide.
You should no longer be setting your adUnitId/adSize in the layout. Instead do:
adView = new AdView(this);
adView.setAdSize(AdSize.SMART_BANNER);
adView.setAdUnitId(AD_UNIT_ID);
Layout:
<com.google.android.gms.ads.AdView
android:id="#+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
And finally,
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice("XXXXXXXXXXXXXXXXXXXX")
.build();
adView.loadAd(adRequest);
I've been trying to solve this problem for weeks. There are some other similar questions in StackOverflow, and there are some (apparently solved) similar issues in AdWhirl documentation website (one and two), but this error is still bothering me.
AdWhirl documentation is rather incomplete and confusing. The steps I've followed:
I created an AdMob account and I got the AdMob ID.
I created an AdWhirl account, I put there the AdMob ID and I got the AdWhirl ID.
I added in my Java Build Path the AdMob SDK Jar 4.3.1 and the AdWhirl SDK Jar 3.1.1
In my Manifest file I added the following lines:
.
<manifest>
[...]
<application>
[...]
<activity android:name="com.google.ads.AdActivity"
android:configChanges="orientation|keyboard|keyboardHidden|screenLayout|uiMode|screenSize|smallestScreenSize" />
<meta-data android:value="[AdWhirl ID]" android:name="ADWHIRL_KEY"/>
</application>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
</manifest>
In all the layouts I want ads I added the following lines:
.
<com.adwhirl.AdWhirlLayout
android:id="#+id/adwhirl_layout"
android:layout_width="fill_parent"
android:layout_height="72dip" />
In all the activities related to those layouts I added the following lines:
.
public class XXX extends ListActivity implements AdWhirlInterface {
[...]
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.YYY);
initAds();
[...]
}
[...]
private void initAds() {
AdWhirlManager.setConfigExpireTimeout(1000 * 60 * 5);
AdWhirlTargeting.setTestMode(false);
AdWhirlLayout adWhirlLayout = (AdWhirlLayout)findViewById(R.id.adwhirl_layout);
adWhirlLayout.setAdWhirlInterface(this);
}
public void adWhirlGeneric() {
Log.e(AdWhirlUtil.ADWHIRL, "In adWhirlGeneric()");
}
}
Project Build Target: Google API Android 4.0
Emulator: Google APIs 2.1 (API 7)
What am I doing wrong?
I see no ads and all the time I get the "nextRation is null!" error.
This looks like pretty much like the minimalistic AdWhirl implementation. FYI, you don't need the adWhirlGeneric() method.
There are a couple of reasons nextRation may be null.
The AdWhirl servers may have been down during the time you had this issue, or that you misconfigured some settings in the AdWhirl UI. These errors are unlikely.
AdWhirl tried to request an AdMob ad, and it failed for whatever reason (my money is on lack of inventory), and AdWhirl had no next ration, meaning there are no more ad networks to try to request an ad from (and it will try again on next refresh).
NOTE: A Ration in AdWhirl represents an ad network settings, like network name and it's corresponding network id.
Check the logcat output again, and see what leads up to the nextRation is null error. Is it a JSONException? If so, that means you have issue #1. Do the logs say you found an AdMob ration, then AdMob responded with onFailedToReceiveAd, and then you get nextRation is null? Then you have issue #2.
I had the same issue and found a solution following this post:
http://code.google.com/p/adwhirl/issues/detail?id=27
Hope it can help you too.
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);
I want to use xml to add a banner ad to my app. To understand how to do this, I read through the Google AdMob Ads Android Banner XML tutorial. There's even example code. However, the example project doesn't display ads on my device (a Motorola xt720). I get nothing relevant in LogCat.
If I go to project settings and remove the 4.0.4 jar and add the 4.1.0 jar that I downloaded with Android SDK and AVD Manager (downloaded "Google Admob Ads Sdk package, revision 2" and the file is android-sdk-linux_86/extras/google/admob_ads_sdk/GoogleAdMobAdsSdk-4.1.0.jar), then I get this in LogCat.
ERROR/Ads(4486): AdView missing
required XML attribute "adSize".
INFO/Ads(4486): To get test ads on
this device, call
adRequest.addTestDevice("00000000000000000000000000000000");
I make that change:
AdRequest adRequest = new AdRequest();
adRequest.addTestDevice("00000000000000000000000000000000");
adView.loadAd(adRequest);
And now I get this:
ERROR/Ads(5018): AdView missing required XML attribute "adSize".
WARN/Ads(5018): Invalid unknown request error: Cannot determine request type. Is your ad unit id correct?
INFO/Ads(5018): onFailedToReceiveAd(Invalid Google Ad request.)
If I edit main.xml to fix the ads:adUnitId to be the value I have in my admob account, I still get the same error. As you can see, I am setting my adSize:
<com.google.ads.AdView
android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId="000000000000000"
ads:adSize="BANNER" />
So in summary:
I fixed the library version
I added my test device
I set my ads:adUnitId
But I still get AdView missing required XML attribute "adSize"
What am I doing wrong?
There are some changes to the way Admob works in version 4.1.0
There's a discussion on Google Groups about this issue and how they haven't updated the documentation.
Google employee Tim posted:
1) Remove attrs.xml (or if you need it for your own custom attributes, remove the parts related to AdViews).
2) Change the namespace in your layout from xmlns:ads="http://schemas.android.com/apk/res/com.your.packagename" to xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
Once you have made those two changes (along with the other changes you already made), you should now see an ad.