Я следую инструкциям в официальной ссылке, и я не могу найти, где проблема. Я скачал эти библиотеки из: https://developers.google.com/mobile-ads-sdk/download#downloadandroid Это мой код: В MainActivity я добавить:Admob: Не удалось инициализировать AdView: Обязательный атрибут XML «adSize» отсутствует
adView = (AdView) findViewById(R.id.ad);
AdRequest adRequest = new AdRequest();
adView.loadAd(adRequest);
В манифесте:
<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" />
И 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>
Это сбой происходит во время работы приложения. Если это так, вы получите полную стек. Также вы можете проверить adUnitId правильно или нет? – Triode
В журнале у меня есть threadid = 1: Не удалось инициализировать AdView: отсутствует атрибут XML adSize; thread exiting with uncaught exception (group = 0x41af1438) – user3118803