Skip to content

I had to add "implementation("com.google.protobuf:protobuf-java:3.24.0")" #40

Closed

Description

@slaszu

I use kotlin. I had to add line implementation("com.google.protobuf:protobuf-java:3.24.0") to my build.gradle.kts to make qdrant java-client works.

Now I have this 2 lines:

implementation("io.qdrant:client:1.9.1")
implementation("com.google.protobuf:protobuf-java:3.24.0")

Secund think, I had to use exacly version 3.24.0, witch is pointed in https://github.com/qdrant/java-client/blob/master/build.gradle#L81

Maybe it because kotlin, but I think it is worth to say it in documentation.

Activity

  1. anush008 commented on Jun 28, 2024

    @anush008
    Member

    com.google.protobuf:protobuf-java:3.24.0 shouldn't be required.

    Could you please describe more about the error/issue you ran into?

  2. Loahrs commented on Jul 3, 2024

    @Loahrs

    Thank you, slazu!

    I encountered the same problem. I also use Kotlin in my project with the newest qdrant-Client (1.10.0).

    I was trying to do a search:

    val searchResults : List<ScoredPoint> =
            client.searchAsync(
                SearchPoints.newBuilder()
                    .setCollectionName("my_dataset")
                    .setLimit(3)
                    .addAllVector(...)
                    .setWithPayload(enable(true))
                    .build()
            ).get()
    

    But then encountered the following errors in my IDE:
    qdrant

    Adding the protobuf-Dependency fixed the errors for me.

  3. anush008 commented on Jul 3, 2024

    @anush008
    Member

    I expected it to be bundled with the project dependencies.
    It seems like, it might be useful to add this as a side note for users.
    Thanks

  4. Loahrs commented on Jul 3, 2024

    @Loahrs

    I expected it to be bundled with the project dependencies. It seems like, it might be useful to add this as a side note for users. Thanks

    As far as I know you would have to change the way your dependencies are added in your gradle.build, if you want to have these dependencies available transitively.

    The libraries dependencies are defined this way:

    dependencies {
    	errorprone "com.uber.nullaway:nullaway:0.10.18"
    
    	implementation "io.grpc:grpc-protobuf:${grpcVersion}"
    	implementation "io.grpc:grpc-services:${grpcVersion}"
    	implementation "io.grpc:grpc-stub:${grpcVersion}"
    	implementation "com.google.guava:guava:30.1-jre"
    	implementation "org.slf4j:slf4j-api:${slf4jVersion}"
    
            //...
    }
    

    note that they are imported using implementation "..." .
    This means your libraries are available during development, but won't be automatically made accessible to a user of the library.

    The issue is that the client libraries methods return Guava-Objects. So Guava-Classes are part of your public facing api and thus part of the library. E.g:

    public ListenableFuture<Points.ScoredPoint>> searchAsync(Points.SearchPoints request) {
        // -> returns a Guava Listenable from com.google.common.util.concurrent
    }
    

    Gradle allows defining dependencies using api "..." which makes dependencies transitive:

    dependencies {
    	errorprone "com.uber.nullaway:nullaway:0.10.18"
    
    	api "io.grpc:grpc-protobuf:${grpcVersion}"
    	implementation "io.grpc:grpc-services:${grpcVersion}"
    	implementation "io.grpc:grpc-stub:${grpcVersion}"
    	api "com.google.guava:guava:30.1-jre"
    	implementation "org.slf4j:slf4j-api:${slf4jVersion}"
    
            //...
    }
    

    A cleaner approach could be to abstract away third party dependencies on public facing api.

    See: https://docs.gradle.org/current/userguide/java_library_plugin.html#sec:java_library_separation

    Also note the explanation here: https://docs.gradle.org/current/userguide/java_library_plugin.html#sec:java_library_recognizing_dependencies

  5. anush008 commented on Jul 3, 2024

    @anush008
    Member

    io.grpc:grpc-protobuf indeed needs to be included in your project.

    OP mentioned about missing com.google.protobuf:protobuf-java, which for me is weird since I expected it to be available with the above.

  6. anush008 commented on Jul 3, 2024

    @anush008
    Member

    Anyways, a note about these dependencies for consumers would be useful. Will do.
    Thank you @slaszu and @Loahrs

  7. Loahrs commented on Jul 3, 2024

    @Loahrs

    io.grpc:grpc-protobuf indeed needs to be included in your project.

    OP mentioned about missing com.google.protobuf:protobuf-java, which for me is weird since I expected it to be available with the above.

    I also had to add the Guava library in my case. The missing com.google.protobuf:protobuf-java should be following the same logic as in my last comment - Because SearchPoints extends a Protobuf-Class but is part of the public API of this library.

    But just adding a note about the needed dependencies might be a simpler thing to do, indeed :)

  8. p-dekker commented on Jul 5, 2024

    @p-dekker

    Using maven and java, I also have issues with class not accessible using the simple example from the readme.

    I do have the tensorflow java bindings as well, so maybe they case havoc as they also use grpc libs.

  9. anush008 commented on Jul 16, 2024

    @anush008
    Member
  10. sven42 commented on Feb 12, 2025

    @sven42

    Hi @anush008,

    thank you for describing a workaround in the Readme.md.

    However, I think it would be better to fix the issue by using the right scopes for the dependencies as suggested by @Loahrs :

            api "io.grpc:grpc-protobuf:${grpcVersion}"
    	implementation "io.grpc:grpc-services:${grpcVersion}"
    	implementation "io.grpc:grpc-stub:${grpcVersion}"
    	api "com.google.guava:guava:30.1-jre"
    	implementation "org.slf4j:slf4j-api:${slf4jVersion}"
    
  11. sven42 commented on Nov 28, 2025

    @sven42

    Hopefully fixed with #93.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions