0

To obtain AAID it is obligatory to add

implementation "com.google.android.gms:play-services-ads:x.y.z"

dependency to dependencies function in gradle file, then implement what's described How to get Advertising ID in android programmatically

But from 17.0.0 version of play-services-ads, according to https://developers.google.com/admob/android/rel-notes#17.0.0 AdMob App ID is required in AndroidManifest.xml. Crash otherwise.

<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>

source: https://developers.google.com/admob/android/quick-start#update_your_androidmanifestxml

It's strange to me. I don't use AdMob, so I don't want to write messy code in AndroidManifest.xml. It looks like this is the way for Google to subtly force usage of AdMob for greenfield projects.

Which dependency is optimal for getting AAID nowadays?

PrzemekTom
  • 1,328
  • 1
  • 13
  • 34

1 Answers1

0

Possible solutions:

  • stay on 16.0.0
  • upgrade to at least 18.3.0 and use sample AdMob App ID
  • upgrade to at least 18.3.0 and set up default project in Firebase AdMob. Provide AdMob App ID from there.

I don't observe any side effect with 1st and 2nd solution. Getting AAID is fine. Haven't tried 3rd, but should be fine.

PrzemekTom
  • 1,328
  • 1
  • 13
  • 34