Errors:

W/Ads: There was a problem getting an ad response. ErrorCode: 0 W/Ads: Failed to load ad: 0 

View code:

 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:ads="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.myapp"> <com.google.android.gms.ads.AdView android:id="@+id/adView" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_alignParentBottom="true" ads:adSize="SMART_BANNER" ads:adUnitId="@string/banner_ad_unit_id"> </com.google.android.gms.ads.AdView> </RelativeLayout> 

Class Code:

 private AdView mAdView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mAdView = (AdView) findViewById(R.id.adView); AdRequest adRequest = new AdRequest.Builder().build(); mAdView.loadAd(adRequest); 

I did everything on the StartAndroid video using Firebase

 <string name="banner_ad_unit_id">"Идентификатор рекламного блока"</string> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> 

What am I doing wrong? AdMod received a letter of congratulations with the first show, but no ads (

    1 answer 1

    In onCreate() there?

     MobileAds.initialize(getApplicationContext(), "Идентификатор рекламного блока"); 

    in Manifest added?

     <activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" android:theme="@android:style/Theme.Translucent" /> 

    com.google.android.gms:play-services-ads:9.6.1 and apply plugin: 'com.google.gms.google-services' are present in Gradle at the application level?

     dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') ... com.google.android.gms:play-services-ads:9.6.1//? } apply plugin: 'com.google.gms.google-services'//? 

    Is the classpath 'com.google.gms:google-services:3.0.0' added to the Gradle at the project level?

     dependencies { classpath 'com.android.tools.build:gradle:2.2.1' classpath 'com.google.gms:google-services:3.0.0'//? } 

    Here is how to test ads in test mode.

    • in MobileAds.initialize (getApplicationContext (), "Ad block identifier"); Should the "ad unit identifier" be the same as banner_ad_unit_id, or the one that wrote the letter with ~ instead of / and another value after it? - Andrey Shpileva
    • @AndreyShpileva from the post - iFr0z
    • @AndreyShpileva solved the problem - iFr0z
    • one
      It turned out the problem in my carelessness, but your answers prompted me to a solution!))) Thank you! - Andrey Shpileva
    • @ Andrei Shpileva was glad to help :) - iFr0z