Google rejects my app and claims ad fraud

Viewed 2222

I am using interstitial ads from Admob in my app. Google rejects my app and claims ad fraud. They say that my app displays an ad after exiting the app. I have changed my ad code to be sure that ad loading and ad displaying only happens when the activity is running and the app is in the foreground. Still they reject my app and claim ad fraud. I am just doing basic interstitial code here:

implementation 'com.google.android.gms:play-services-ads:19.7.0'

public class AdManager {
    boolean activityStarted;

    public void onStart() {
        activityStarted=true;
    }

    public void onStop() {
        activityStarted=false;
    }

    public void initializeAds(Context context) {
        MobileAds.initialize(context);
        MobileAds.setAppMuted(true);
        List<String> testDeviceIds = Arrays.asList("some id");
        RequestConfiguration configuration =
                new RequestConfiguration.Builder().setTestDeviceIds(testDeviceIds).build();
        MobileAds.setRequestConfiguration(configuration);
    }

    public InterstitialAd getInterstialAdWithUnit(Context context) {
        InterstitialAd mInterstitialAd = new InterstitialAd(context);
        mInterstitialAd.setAdUnitId(BuildConfig.INTERSTITIAL_AD_UNIT_ID);
        setAdListener(mInterstitialAd);
        checkNewAdNeeded(mInterstitialAd);
        return mInterstitialAd;
    }

    public void setAdListener(InterstitialAd mInterstitialAd) {
        mInterstitialAd.setAdListener(new AdListener() {
            @Override
            public void onAdClosed() {
                super.onAdClosed();
                checkNewAdNeeded(mInterstitialAd);
            }
        });
    }

    public void showAdIfNeeded(InterstitialAd mInterstitialAd) {
        if (activityStarted && mInterstitialAd.isLoaded())
            mInterstitialAd.show();
        else {
            checkNewAdNeeded(mInterstitialAd);
        }
    }


    public void requestNewInterstitial(InterstitialAd mInterstitialAd) {
        AdRequest adRequest = new AdRequest.Builder()
                .build();
                
        mInterstitialAd.loadAd(adRequest);
    }

    public void checkNewAdNeeded(InterstitialAd mInterstitialAd) {
        //do not load ad when acticity is stopped
        if (activityStarted && !mInterstitialAd.isLoading() && !mInterstitialAd.isLoaded())
            requestNewInterstitial(mInterstitialAd);
    }
}


public class FullscreenActivity extends AppCompatActivity {
    AdManager adManager=new AdManager();

    public void onButtonClicked() {
        //call another activity when Button is clicked and wait for return to display ad
        activity.startActivityForResult(intent, requestCode);
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                adManager.checkNewAdNeeded(mInterstitialAd);
            }
        });
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        //back from other activity, try to display ads only if app has focus
        if ( from activity xy) {
            if (mHasFocus)
                showAdWhileHasFocus();
            else
                showAdWhenHasFocus=true;
        }
    }

    @Override
    protected void onStart() {
        super.onStart();
        adManager.onStart();
    }

    @Override
    protected void onStop() {
        adManager.onStop();
        super.onStop();
    }

    boolean showAdWhenHasFocus;


    public void showAdWhileHasFocus() {
        showAdWhenHasFocus=false;
        adManager.showAdIfNeeded(mInterstitialAd,promotionAndAdsEvent);
    }


   boolean mHasFocus=false;

    @Override
    public void onWindowFocusChanged(boolean hasFocus) {
        if (!hasFocus) {
        } else {
            if (showAdWhenHasFocus)
                showAdWhileHasFocus();
        }
        super.onWindowFocusChanged(hasFocus);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }  
}

3 Answers

I recently faced this issue. But got my app update approved after the following update:

We were having Interstitial ad right while opening the app, This was causing the next screen (Home dashboard) banner ad to hide behind the interstitial add. So I removed the interstitial. This got us the problem fixed.

It might be that playstore/Admob doesn't accept ad at app start, Might be they are trying to force us to use their app open ad instead of interstitial or any other ad unit.

In my case it turned out to be an old version in the test track. In the first version I had an interstitial when exiting the app - which is not allowed. I fixed the issue, but still my app got rejected. After about 10 more tries, I realized that the first version of the app (with the interstitial on exit) was still in the test track, so I removed (or updated) the test track version, and my app was approved.

Seems like after 5 months of app rejections with ad fraud claims my apps are passing review process again. The final change I made was to change the Interstitial class in my AdMob lib to the new API.

import com.google.android.gms.ads.interstitial.InterstitialAd;
InterstitialAd mInterstitialAd;

MobileAds.initialize(...
mInterstitialAd.setFullScreenContentCallback(...
mInterstitialAd.show(...

Admob has made a lot of restructuring and I was using the legacy API. Though it was not declared as legacy until a few weeks ago. The first claim was for version 19.4.0 (https://developers.google.com/admob/android/rel-notes) and it continued until version 19.7.0. Here is a discussion about the topic. https://groups.google.com/g/google-admob-ads-sdk/c/XTJ9kcgxvbY

Related