Android compilation error after upgrading to 'com.google.android.gms:play-services-ads:18.1.0'

拈花ヽ惹草 提交于 2021-02-10 16:40:36

问题


I am upgrading my play-services-ads library from version 12 to version 18.1:

dependencies {
    api 'com.google.android.gms:play-services-ads:18.1.0'
}

The problem is that the compilation fails with this error:

.gradle/caches/transforms-1/files-1.1/play-services-ads-identifier-17.0.0.aar/75b3c9fbdc51199269673bd2fa8b6cfe/jars/classes.jar(com/google/android/gms/ads/identifier/AdvertisingIdClient.class): warning: Cannot find annotation method 'value()' in type 'GuardedBy': class file for javax.annotation.concurrent.GuardedBy not found

I took away all the usages for AdvertisingIdClient and left only the import, but the problem persists:

import com.google.android.gms.ads.identifier.AdvertisingIdClient;

Is there anything I am doing wrong?


回答1:


com.google.android.gms:play-services-ads:18.1.0 depends upon com.google.android.gms:play-services-ads-identifier:17.0.0, among other libraries.

Your error indicates that com.google.android.gms:play-services-ads-identifier:17.0.0 references javax.annotation.concurrent.GuardedBy. However, that class is not in the Android SDK. The POM file for com.google.android.gms:play-services-ads-identifier:17.0.0 should be referencing a library that has an implementation of that class, but it does not seem to.

One library that has an implementation of that class is com.google.code.findbugs:jsr305. Adding a dependency on com.google.code.findbugs:jsr305 for a recent version (e.g., 3.0.2) gave you that class, satisfying the compiler.

So, there appears to be a bug in the Play Services SDK packaging, which my workaround resolves. You might want to add a comment in your module's build.gradle file to consider removing the com.google.code.findbugs:jsr305 if a future update to com.google.android.gms:play-services-ads fixes this bug.



来源:https://stackoverflow.com/questions/57118368/android-compilation-error-after-upgrading-to-com-google-android-gmsplay-servic

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!