MoPub banner ads

122 Views Asked by At

I am trying to add MoPub banner to my app and i've got error in logs: Unable to obtain Google AdvertisingIdClient.Info via reflection. Am i doing something wrong? P.S I am using test ad ID.

   @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    moPubViewBanner=(MoPubView)findViewById(R.id.banner_ad);
    moPubViewBanner.setAdUnitId("b195f8dd8ded45fe847ad89ed1d016da");

    SdkConfiguration sdkConfiguration = new SdkConfiguration.Builder("MOPUB_ID")
            .withLogLevel(MoPubLog.LogLevel.DEBUG)
            .withLegitimateInterestAllowed(false)
            .build();

    MoPub.initializeSdk(this, sdkConfiguration, new SdkInitializationListener() {
        @Override
        public void onInitializationFinished() {
            Log.d("Mopub", "SDK initialized");
          
            moPubViewBanner.loadAd();
        }
    });

}
1

There are 1 best solutions below

0
andzrev On

You need to integrate Google Play services:

com.google.android.gms:play-services-ads-identifier

Get the latest version at https://developers.google.com/android/guides/releases.