AdMob in Android emulator not visible?
You have to using some from this libraries:
GoogleAdMobAdsSdk-4.3.1.jar
GoogleAdMobAdsSdk-6.0.1.jar
GoogleAdMobAdsSdk-6.2.1.jar
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="cz.okhelp.admob" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="13" android:targetSdkVersion="16"/> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name"> <meta-data android:value="a14d932xxxxxxxx" android:name="ADMOB_PUBLISHER_ID" /> <activity android:name=".AdmobActivity" 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>
onCreate in your Activity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); AdViw adView = new AdView(this, AdSize.BANNER, "a14d932xxxxxxxxx");//MY_AD_UNIT_ID LinearLayout layout = (LinearLayout)findViewById(R.id.idReklamaLayout); // Add the adView to it layout.addView(adView); // Initiate a generic request to load it with an ad AdRequest adRequest = new AdRequest(); //adRequest.setTesting(true); adRequest.setGender(AdRequest.Gender.MALE); adView.loadAd(adRequest); }
main.xml (res/layout)
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/idReklamaLayout" android:orientation="vertical" android:gravity="center" android:layout_width="fill_parent" android:layout_height="wrap_content" /> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="3" /> </LinearLayout>