Reputation: 11
I follow the steps in the official link, and I can't find where is the problem. I have downloaded the libs from: https://developers.google.com/mobile-ads-sdk/download#downloadandroid This is my code: In MainActivity i add:
adView = (AdView) findViewById(R.id.ad);
AdRequest adRequest = new AdRequest();
adView.loadAd(adRequest);
In Manifest:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<activity android:name="com.google.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
And the xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/lytMain"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/libs/com.google.ads"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<com.google.ads.AdView
android:id="@+id/ad"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-xxxxxxxx/xxxxxx"
ads:testDevices="TEST_EMULATOR"
ads:loadAdOnCreate="true" >
</com.google.ads.AdView>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="2"
android:gravity="center"
>
<TextView
android:id="@+id/cargando"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Cargando resultados..."
android:textColor="@android:color/black"
android:textSize="20sp" />
<ProgressBar
android:id="@+id/progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@android:style/Widget.ProgressBar.Small.Inverse"
android:layout_marginRight="5dp" />
<Button
android:id="@+id/button"
android:visibility="invisible"
android:layout_marginTop="10dp"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Ver resultados" />
</LinearLayout>
</LinearLayout>
Upvotes: 1
Views: 2998
Reputation: 1304
In the newest SDK:
XML:
<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:adSize="BANNER"
ads:adUnitId="xxxxxxxxxxxxxxxxxxxx" />
Code:
adView = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
adView.loadAd(adRequest);
Upvotes: 1
Reputation: 998
Try editing this and use.
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res/com.jms.AdmobExample"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<com.google.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res/com.jms.AdmobExample"
android:id="@+id/add_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ns:adSize="BANNER"
ns:adUnitId="a14f1d807e488dd" >
</com.google.ads.AdView>
</Linearlayout>
Upvotes: 0