Я хотел бы разместить рекламу в моем MainActivity ниже FrameLayout так:вопросов AdMob баннер андроид
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity"
xmlns:ads="http://schemas.android.com/apk/res-auto">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:id="@+id/fragmentContainer"
android:layout_centerHorizontal="true">
</FrameLayout>
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="@string/banner_ad_unit_id">
</com.google.android.gms.ads.AdView>
Я добавил это к моему манифесту: <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version"/>
И моя сборка .gradle тоже отлично выглядит. Вот мой код Java:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
MobileAds.initialize(getApplicationContext(),"ca-app-pub-xxxxxxxx~xxx");
AdView mAdView = (AdView) findViewById(R.id.adView);
AdRequest request = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR) // An example device ID
.build();
mAdView.loadAd(request);
Но когда я запустить приложение, я не могу видеть рекламу, а в LogCat я получил эту ошибку:
W/Ads: Invalid unknown request error: [Cannot determine request type. Is your ad unit id correct?]
W/Ads: There was a problem getting an ad response. ErrorCode: 1
W/Ads: Failed to load ad: 1
Я пробовал почти все, что нашел в Интернете, но ничего не работало для меня. Я думаю, может быть, проблема в моем activity_main.xml из-за того, что FrameLayout не дает достаточно места для рекламы.