error: cannot access CheckReturnValue

270 views
Skip to first unread message

Kevin Jimenez

unread,
Jun 15, 2023, 9:55:37 PM6/15/23
to Protocol Buffers
I am trying to install grpc for Android with access to Timestamp. The generated code generates ok but the project throws this error. I did some research and it looks like it has to do with guava. Attached is my app build.grade:

Error 

> Task :app:compileDevDebugJavaWithJavac
error: cannot access CheckReturnValue
  class file for javax.annotation.CheckReturnValue not found
cannot access CheckReturnValue

Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 error

Build Gradle Snippet
`` 

    // You need to build grpc-java to obtain these libraries below.
    implementation 'io.grpc:grpc-okhttp:1.55.1' // CURRENT_GRPC_VERSION
    implementation 'io.grpc:grpc-protobuf-lite:1.55.1' // CURRENT_GRPC_VERSION
    implementation 'io.grpc:grpc-stub:1.55.1' // CURRENT_GRPC_VERSION
    implementation 'org.apache.tomcat:annotations-api:6.0.53'
    implementation 'com.google.protobuf:protobuf-javalite:3.23.2'
    implementation("com.google.protobuf:protobuf-java:3.23.0") {
        exclude(group: 'com.google.guava', module: 'guava')
        exclude(group: 'org.checkerframework', module: 'checker-compat-qual')
        exclude(group: 'javax.annotation', module: 'jsr250-api')
        exclude(group: 'io.opencensus', module: 'opencensus-api')
        exclude(group: 'com.google.errorprone', module: 'error_prone_annotations')
        exclude(group: 'com.google.protobuf', module: 'protobuf-javalite')
        exclude(group: 'io.grpc', module: 'grpc-context')
    }
//    implementation 'com.google.errorprone:error_prone_annotations:2.18.0'
//    implementation("com.google.guava:guava:32.0.1-android")
    //protobuf 'com.google.protobuf:protobuf-java:3.23.0'
}

protobuf {
    protoc { artifact = 'com.google.protobuf:protoc:3.23.2' }
    plugins {
        grpc {
            artifact = 'io.grpc:protoc-gen-grpc-java:1.55.1' // CURRENT_GRPC_VERSION
        }
    }
    generateProtoTasks {
        all().each { task ->
            task.builtins {
                java { option 'lite' }
            }
            task.plugins {
                grpc { // Options added to --grpc_out
                    option 'lite'
                }
            }
        }
    }
}
```

Thanks in advance! Lmk if you want any more info

Deanna Garcia

unread,
Jun 16, 2023, 12:55:09 PM6/16/23
to Protocol Buffers
I think you're right that this is likely a problem with guava. Can you try posting a bug in their repo?

Kevin Jimenez

unread,
Jun 16, 2023, 12:59:21 PM6/16/23
to Protocol Buffers
When I remove 
implementation("com.google.protobuf:protobuf-java:3.23.0") {
        exclude(group: 'com.google.guava', module: 'guava')
        exclude(group: 'org.checkerframework', module: 'checker-compat-qual')
        exclude(group: 'javax.annotation', module: 'jsr250-api')
        exclude(group: 'io.opencensus', module: 'opencensus-api')
        exclude(group: 'com.google.errorprone', module: 'error_prone_annotations')
        exclude(group: 'com.google.protobuf', module: 'protobuf-javalite')
        exclude(group: 'io.grpc', module: 'grpc-context')
    }
}
Timestamp does not get recognized, but CheckReturnValue problem is gone.  On the other side when I add it I get CheckReturnValue error. Do you have any idea if the problem is with the protobuf-java or the guava dependency?
Reply all
Reply to author
Forward
0 new messages