How to implement AdMob GDPR message in Android application

If you are an Android developer and looking for AdMob GDPR implementation then you are in the right place. In this tutorial, I will share with you how to implement AdMob GDPR Message in an Android application. So let’s start.

Beginning of January 2024 all Android developers need to implement Admob GDPR message to server ads in the European Union and the United Kingdom. Without getting consent from the user no ad will appear in your Android app. So It’s most important for setting up the GDPR Message. Let’s Implement the GDPR message.


implementation ''
First, go to your app build. gradle file add this dependency and click to sync button. After successful sync, AdMob UMP SDK will be added in your project. 


Now go to your app activity and select an activity where you want to set up a GDPR message. Declare these two variables outside the OnCreate method.

private ConsentInformation consentInformation;

private final AtomicBoolean isMobileAdsInitializeCalled = new AtomicBoolean(false);

Now to go your OnCreate Method and paste this code. The code is given below

 ConsentDebugSettings debugSettings = new ConsentDebugSettings.Builder(this)

        ConsentRequestParameters params = new ConsentRequestParameters

        consentInformation = UserMessagingPlatform.getConsentInformation(this);
                (ConsentInformation.OnConsentInfoUpdateSuccessListener) () -> {
                            (ConsentForm.OnConsentFormDismissedListener) loadAndShowError -> {
                                if (loadAndShowError != null) {
                                    // Consent gathering failed.
                                    Log.w(TAG, String.format("%s: %s",

                                // Consent has been gathered.
                                if (consentInformation.canRequestAds()) {
                (ConsentInformation.OnConsentInfoUpdateFailureListener) requestConsentError -> {
                    // Consent gathering failed.
                    Log.w(TAG, String.format("%s: %s",

        // Check if you can initialize the Google Mobile Ads SDK in parallel
        // while checking for new consent information. Consent obtained in
        // the previous session can be used to request ads.
        if (consentInformation.canRequestAds()) {

Before Publishing your app in the Play Store, remove the debug setting.

Now go to outside of OnCreate Method and declare this Method.

 private void initializeMobileAdsSdk() {

You have to load your admob ad in this method. All the Processes are shared in my video.

If you have any confusion, Watch my YouTube video. The video link is given below


Leave a Reply

Your email address will not be published. Required fields are marked *