Reputation: 5681
I use admob and millennial media ads.
I am not receiving any millennial media ads probably to low fill rate.(i want to solve the admob problem first).
As for admob ads ,they show up in the emulator (using ads:testDevices="TEST_EMULATOR, TEST_DEVICE_ID") but they don't show in real phone.
Also, sometimes i receive a message:
An error occurred while loading data in AdWebView:
E/Ads(280): java.lang.NullPointerException
E/Ads(280): at android.webkit.WebView.loadDataWithBaseURL(WebView.java:1626)
E/Ads(280): at com.google.ads.h.loadDataWithBaseURL(SourceFile:128)
E/Ads(280): at com.google.ads.c$c.run(SourceFile:142)
and :
W/webcore ( 915): Can't get the viewWidth after the first layout
I use the lastest sdks for android and admob.
I also did
target=android-13 in project.properties file.
I use admob like this:
<com.google.ads.AdView android:id="@+id/adView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="....."
ads:loadAdOnCreate="true"
ads:refreshInterval="30"
and in manifest:
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
Any ideas?
Thanks!
Upvotes: 2
Views: 5570
Reputation: 8931
When using ads:testDevices="TEST_EMULATOR, TEST_DEVICE_ID"
, the TEST_DEVICE_ID
should be replaced with your device id to get test ads on your device. The id that AdMob uses is a hashed version of your phone's device id though, so you will need to get the value from LogCat (it may be different than the unique device identifier used for millennial). If you make an ad request on your device, your phone should spit out a log at the info level that says:
I/Ads: To get test ads on this device, call adRequest.addTestDevice("THIS_WILL_BE_YOUR_HASHED_DEVICE_ID");
Use the hashed device id provided in order to get test ads on your device. You can release with this code in there. All other devices will have a different id, so they will get live ads and not test ads.
The An error occurred while loading data in AdWebView
error message is a known issue with Android's WebView that was caught and logged by the SDK. It really should be logged at the warn level, because it doesn't crash the app.
Also, I'm not sure why the webcore warning is logged, but I see it all the time myself, and it doesn't seem to have any effect.
Upvotes: 3
Reputation: 11
You can try following Code in .manifest file you can use
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation"/>
in .xml file file
xmlns:ads="http://schemas.android.com/apk/res/your-package-Name"
<com.google.ads.AdView android:id="@+id/adView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
ads:adUnitId="674f76af93c2678d"//your application unit Id write here
ads:adSize="BANNER"/>
In .java file write simple code
import com.google.ads.AdRequest;
import com.google.ads.AdView;
AdView adv = (AdView)findViewById(R.id.adView);
// Initiate a generic request to load it with an ad
AdRequest re = new AdRequest();
re.setTesting(true);
adv.loadAd(re);
//==============================
Upvotes: 1