如何解决android,如果需要 AdvertisingIdClient 使用哪个依赖项
具有获取 AdvertisingIdClient.Info 的函数
private static AdvertisingIdClient.Info getAdsClientInfo(@NonNull final Context context) throws GooglePlayServicesNotAvailableException,IOException,GooglePlayServicesRepairableException {
int isGPAvailable = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(context);
if (isGPAvailable == ConnectionResult.SUCCESS) {
return AdvertisingIdClient.getAdvertisingIdInfo(context);
}
return null;
}
它使用 AdvertisingIdClient.getAdvertisingIdInfo(context)
https://developers.google.com/android/guides/setup 中有三个库
Google Mobile Ads com.google.android.gms:play-services-ads:20.1.0
Android Advertising ID (AAID) com.google.android.gms:play-services-ads-identifier:17.0.0
Lightweight version of Google Mobile Ads com.google.android.gms:play-services-ads-lite:20.1.0
这些有什么区别,哪一个可以安全地用于此目的?
解决方法
事实证明 com.google.android.gms:play-services-ads-identifier:17.0.0
适合这种情况,但将 GoogleApiAvailability
更改为 GoogleApiAvailabilityLight
它将包含在此依赖项中。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。