Additional Google AdMob steps - cleveradssolutions/CAS-Android GitHub Wiki

Add Google Ads App ID

Note

The CAS Gradle Plugin will automatically add the required Google App ID to the application manifest.

Important

You cannot use your own identifier and must replace it with a new one generated by CAS system.

No plugin integration

CAS assigns a new AdMob App ID for your application to the correct operation of all features.

You can find your Admob App ID in the CAS UI: image

  1. Click the Show AdMob App ID button.
  2. Copy the id from the form.
  3. Add a <meta-data> tag with android:name="com.google.android.gms.ads.APPLICATION_ID" in your app's AndroidManifest.xml file.
  4. Insert AdMob app ID to android:value, surrounded by quotation marks, as shown below.
<manifest>
  <application>
    ...
    <!-- Sample AdMob App ID: ca-app-pub-3940256099942544~3347511713 -->
    <meta-data
        android:name="com.google.android.gms.ads.APPLICATION_ID"
        android:value="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy"/>
  </application>
</manifest>

Note that failure to add the <meta-data> tag as shown above results in a crash with the message:

The Google Mobile Ads SDK was initialized incorrectly.

Google Ads Consent for cookies

If your app has special requirements, you can set the optional SharedPreferences gad_has_consent_for_cookies.
The Google Mobile Ads SDK will enable limited ads (LTD) when the gad_has_consent_for_cookies preference is set to zero.

SharedPreferences sharedPreferences =
  PreferenceManager.getDefaultSharedPreferences(context);
sharedPreferences.edit().putInt("gad_has_consent_for_cookies", 0).apply();
⚠️ **GitHub.com Fallback** ⚠️