error-prone icon indicating copy to clipboard operation
error-prone copied to clipboard

class file for com.google.errorprone.annotations.RestrictedInheritance not found

Open TWiStErRob opened this issue 2 years ago • 5 comments

Just updated Google Places SDK from 3.3.0 to 3.4.0 which bumped play-services-base from 18.0.1 to 18.3.0, resulting in the following problems:

compileDebugJavaWithJavac FAILED
Z:\caches\gradle\caches\transforms-3\cafb58f4ccde6f6fe4b7ef5eb9b091ac\transformed\play-services-base-18.3.0-api.jar(/com/google/android/gms/common/GoogleApiAvailability.class): warning: Cannot find annotation method  'explanation()' in type 'RestrictedInheritance': class file for com.google.errorprone.annotations.RestrictedInheritance not found
Z:\caches\gradle\caches\transforms-3\cafb58f4ccde6f6fe4b7ef5eb9b091ac\transformed\play-services-base-18.3.0-api.jar(/com/google/android/gms/common/GoogleApiAvailability.class): warning: Cannot find annotation method  'link()' in type 'RestrictedInheritance'
Z:\caches\gradle\caches\transforms-3\cafb58f4ccde6f6fe4b7ef5eb9b091ac\transformed\play-services-base-18.3.0-api.jar(/com/google/android/gms/common/GoogleApiAvailability.class): warning: Cannot find annotation method  'allowedOnPath()' in type 'RestrictedInheritance'
Z:\caches\gradle\caches\transforms-3\cafb58f4ccde6f6fe4b7ef5eb9b091ac\transformed\play-services-base-18.3.0-api.jar(/com/google/android/gms/common/GoogleApiAvailability.class): warning: Cannot find annotation method  'allowlistAnnotations()' in type 'RestrictedInheritance'
error: warnings found and -Werror specified
1 error
4 warnings

Can you please add the RestrictedInheritance annotation and checker to the error-prone artifacts? or hide the private annotation from the public API.

TWiStErRob avatar Mar 20 '24 09:03 TWiStErRob

Workaround

Create a new file at src/main/java/com/google/errorprone/annotations/RestrictedInheritance.java in the module that uses play-services-base:

package com.google.errorprone.annotations;

/**
 * Workaround for <code>class file for com.google.errorprone.annotations.RestrictedInheritance not found</code>.
 *
 * <pre><code>
 * warning: Cannot find annotation method 'explanation()' in type 'RestrictedInheritance'
 * warning: Cannot find annotation method 'link()' in type 'RestrictedInheritance'
 * warning: Cannot find annotation method 'allowedOnPath()' in type 'RestrictedInheritance'
 * warning: Cannot find annotation method 'allowlistAnnotations()' in type 'RestrictedInheritance'
 * </code></pre>
 *
 * @see <a href="https://github.com/google/error-prone/issues/4335">Report</a>
 */
public @interface RestrictedInheritance {
	String explanation();
	String link();
	String allowedOnPath();
	Class<?>[] allowlistAnnotations();
}

TWiStErRob avatar Mar 20 '24 09:03 TWiStErRob

Thanks for the report!

Can you please add the RestrictedInheritance annotation and checker to the error-prone artifacts? or hide the private annotation from the public API.

We may eventually finalize the annotation to and include it in error-prone-annotations, but until that happens I have filed an internal issue against the owners of play-services-base about hiding the annotation from the API [b/330519201].

cushon avatar Mar 20 '24 15:03 cushon

Thanks for forwarding the issue internally!

TWiStErRob avatar Mar 20 '24 22:03 TWiStErRob

Any progress in this? I'm using these Google libs and they simple do not work:

implementation("com.google.android.gms:play-services-auth:21.3.0")
implementation("com.google.android.gms:play-services-auth-api-phone:18.2.0")
Compilation failed; see the compiler output below. /Users/tapani/.gradle/caches/8.12/transforms/fc4ab65db27b77b03a94362ef9606e5a/transformed/play-services-base-18.5.0-api.jar(/com/google/android/gms/common/GoogleApiAvailability.class): warning: Cannot find annotation method 'explanation()' in type 'RestrictedInheritance': class file for com.google.errorprone.annotations.RestrictedInheritance not found 1 error 100 warnings * Try:
Run with --scan to get full insights. BUILD FAILED in 1m 40s.

tapz avatar Apr 07 '25 08:04 tapz

The issue with play-services-base should have been fixed in version 18.6.0

cushon avatar Apr 07 '25 14:04 cushon