AdView.loadAd () crashes my entire program

I am trying to integrate admob advertisements into my application and I am trying to follow tutorials in the Google APIs and their code leads to the failure of my entire application.

I want to think about it because I am testing my phone, and I did not turn it on adRequest.addTestDevice("TEST_DEVICE_ID");, because in order to get the identifier of your device, you first need to request an ad, and I can not specify exactly where I request an ad.

This is what I have in my main.java line for a line from android api tutorials. The log cat says it crashed intoadView.loadAd(adRequest);

 // Look up the AdView as a resource and load a request.
    AdView adView = (AdView)this.findViewById(R.id.adView);
    AdRequest adRequest = new AdRequest.Builder().build();
    adView.loadAd(adRequest);

Here is xml

 <com.google.android.gms.ads.AdView
        android:id="@+id/adView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        ads:adSize="BANNER"
        ads:adUnitId="ca-app-pub-6084800927799418/5313591087<- this is actually mine"
        />

and finally, here is what log cat has to say: http://imgur.com/UfB45YF

api link: https://developers.google.com/mobile-ads-sdk/docs/admob/fundamentals#play

, , ? - ?

+4
3

adView.loadAd NullPointerException, View, R.id.adView .

onCreate setContentView. , - libGDX AndroidApplication, ContentView.

.

+5

MainActivity.java, , :

activity_main.xml sw600dp\activity_main.xml sw720dp\activity_main.xml

com.google.android.gms.ads.AdView xml , , .

. , . , .

+1

I had the same problem. When I was debugging, I saw an error related to the wrong version number of Google gaming services, and it showed real value. I added this value to the strings.xml file:

<integer name="google_play_services_version">7095000</integer>

As soon as he appeared, everything went fine.

0
source

Source: https://habr.com/ru/post/1534925/


All Articles