I was trying to integrate admob banner in my application several hours, but I couldn't do that, so I created new app the only purpose of which is show admob banner but it doesn't work too. here is code
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AdView adView = new AdView(this, AdSize.BANNER, "XXX");
adView.setVisibility(View.VISIBLE);
RelativeLayout layout = new RelativeLayout(this);
RelativeLayout.LayoutParams adParams =
new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
adParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
layout.addView(adView, adParams);
setContentView(layout);
AdRequest adRequest = new AdRequest();
adView.loadAd(adRequest);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
and here is my manifest file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.zzzzzz_admobtest"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.zzzzzz_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>
what am I doing wrong?
Also, when I output adView.isActivated() and adView.isReady() they both are false.
I am using "XXX" instead of ID because I don't have one. Could it be a problem?
I am using device. Here is errors on ligcat
08-07 22:43:04.248: E/ActivityThread(24181): Failed to find provider info for com.google.plus.platform 08-07 22:43:04.454: E/Ads(24181): JS: Uncaught ReferenceError: AFMA_getSdkConstants is not defined (http://media.admob.com/:1) 08-07 22:43:04.454: E/Web Console(24181): Uncaught ReferenceError: AFMA_getSdkConstants is not defined at http://media.admob.com/:1
the last 2 errors could be fixed by this code
(new Thread() {
public void run() {
Looper.prepare();
adView.loadAd(new AdRequest());
}
}).start();
as I understand the first one is not an error but just a warning. so why this isn't work??