I have tried to use Admob in my application and i have tried the following. could you please tell me why i'm getting this error?
activity.main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"/>
<com.google.ads.AdView android:id="@+id/ad"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="/6253334/dfp_example_ad"
ads:testDevices="TEST_EMULATOR,DB5C6285034D8192153E5D66D726E418"
ads:loadAdOnCreate="true"/>
</LinearLayout>
MainActivity.java
package test.admobtest;
import com.google.ads.AdRequest;
import com.google.ads.AdView;
import android.os.Bundle;
import android.os.Looper;
import android.app.Activity;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final AdView adView = (AdView)this.findViewById(R.id.ad);
new Thread(){
public void run() {
Looper.prepare();
AdRequest re = new AdRequest();
re.setTesting(true);
adView.loadAd(re);
};
}.start();
}
}
AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="test.admobtest"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="test.admobtest.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
</application>
</manifest>
log:
07-08 10:34:34.589: I/webclipboard(26978): clipservice: android.sec.clipboard.ClipboardExManager@4052f5d0
07-08 10:34:34.849: I/webclipboard(26978): clipservice: android.sec.clipboard.ClipboardExManager@4052f5d0
07-08 10:34:34.909: E/ActivityThread(26978): Failed to find provider info for com.google.plus.platform
07-08 10:34:34.929: W/Ads(26978): loadAd called while the ad is already loading, so aborting.
07-08 10:34:34.979: I/Ads(26978): adRequestUrlHtml: <html><head><script src="http://media.admob.com/sdk-core-v40.js"></script><script>AFMA_getSdkConstants();AFMA_buildAdURL({"preqs":1,"session_id":"10000751322559007096","seq_num":"2","slotname":"\/6253334\/dfp_example_ad","u_w":320,"msid":"test.admobtest","adtest":"on","js":"afma-sdk-a-v6.4.1","bas_off":0,"net":"wi","app_name":"1.android.test.admobtest","hl":"en","gnt":3,"carrier":"40440","u_audio":3,"kw":[],"u_sd":1,"ms":"n54ldDZ15bdyTg9xXgxtdXMgomxIrXGdOYvqk2l8bUwTFSRmnmpAVljV0IHyknLTNWRCdF8oj52F_2JERnz-3C-DJsIQ9wGFBnH88tqEb9BjAtNZ3-ni5am3uWBAyUygwgpiyTTzY6cgUeA4g_QnU5Qrh3savu2bMY_3nsjuW9fH7W7x-5HC_oDuaVe6U05Pypm5FMyWGYFqBd0-s6_p_IFm0AhPOYvujrNtCxqC4inyELVT2E0laAKwjvaWVqA5yzjILYNspqByel6t3TMiiZ3z3k7Qc9HYIRsHwRV3cbdtSb_pk5eZCgjTZhaippVWsXwUC-eoMxMdBtfqUHqA9w","mv":"80210006.com.android.vending","isu":"DB5C6285034D8192153E5D66D726E418","format":"320x50_mb","oar":0,"ad_pos":{"height":0,"visible":0,"y":0,"x":0,"width":0},"u_h":480,"pt":1,"bas_on":0,"ptime":20956});</script></head><body></body></html>
07-08 10:34:34.999: W/webcore(26978): Can't get the viewWidth after the first layout
I have tried the following and working now
Work With Admob - put jar file and set path:
download AdMob SDK from Google site(could be a different link depends on country) https://developers.google.com/mobile-ads-sdk/download?hl=de
unzip the file into a directory (no matter where)
create a "libs" folder inside your project in Eclispe. BE SURE THAT THE FOLDER IS NAMED "libs" AND NOT "lib". THIS MISTAKE IS OFTEN DONE
copy the jar file from admob folder into Your project into the libs folder click right mouse button on jar file inside lib folder and choose Build Path-->add to build path
Referred from Android app fail to start after adding admob