0

I have created a Mopub account and got my MarketPlace approved. I have created an app and a Banner unit and trying to see ads in my android app. When I use the test banner Id, it shows me the test banner ad. When I replace the test unit Id with my actual unit Id, I'm not able to see any ads. When I see the log, it shows as No ads .

I thought there were no ads available in MarketPlace to show and hence I have created a unity ads network and tried, but no luck.

Here is my config.

    implementation('com.mopub:mopub-sdk:5.8.0@aar') {
        transitive = true
    }

    // Unity Ads
    implementation 'com.unity3d.ads:unity-ads:3.2.0'
    implementation 'com.mopub.mediation:unityads:3.2.0.0'

I have this in my Launcher Activity.

final SdkConfiguration.Builder configBuilder = new SdkConfiguration.Builder(
                getString(R.string.adUnitId))
                .withLogLevel(DEBUG);
        MoPub.initializeSdk(this, configBuilder.build(), () -> Log.d("Mopub", "SDK initialized"));

Here is the code from the activity where I load the ad.

moPubView = findViewById(R.id.adview);
        moPubView.setAdUnitId(getString(R.string.adUnitId));
        moPubView.loadAd(MoPubView.MoPubAdSize.HEIGHT_250);

Here is the log I am getting.

I/MoPub: [com.mopub.network.AdLoader$a][onErrorResponse] Ad server responded with:
    No ads found for ad unit.
I/MoPub: [com.mopub.mobileads.AdViewController][a] SDK Log - Ad failed to load.
I/MoPub: [com.mopub.mobileads.MoPubView][a] Ad failed to load: (10,000) No ads found.

Can anyone please assist !!!

i.am.jabi
  • 620
  • 1
  • 5
  • 23

1 Answers1

0

If your R.string.adUnitId is a live adUnitID this behaviour is expected. There is just no ad that fits. You should test the implementation with MoPubs test_adUnitIds.

Change your init process to make use of the ternary operator if your in debug mode.

final SdkConfiguration.Builder configBuilder = new SdkConfiguration.Builder(
            BuildConfig.DEBUG ? "252412d5e9364a05ab77d9396346d73d" : getString(R.string.adUnitId))
            .withLogLevel(DEBUG);
    MoPub.initializeSdk(this, configBuilder.build(), () -> Log.d("Mopub", "SDK initialized"));

Same for your moPubView.

moPubView = findViewById(R.id.adview);
    moPubView.setAdUnitId(BuildConfig.DEBUG ? "252412d5e9364a05ab77d9396346d73d" : getString(R.string.adUnitId));
    moPubView.loadAd(MoPubView.MoPubAdSize.HEIGHT_250);
S. Gissel
  • 1,788
  • 2
  • 15
  • 32