Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Couldn't find constructor 'GrpcServiceName'. #866

Open
wheeOs opened this issue Aug 9, 2023 · 9 comments
Open

Error: Couldn't find constructor 'GrpcServiceName'. #866

wheeOs opened this issue Aug 9, 2023 · 9 comments

Comments

@wheeOs
Copy link

wheeOs commented Aug 9, 2023

My proto dart files are generated by protoc_plugin version 21.0.2 with

protoc --version
libprotoc 3.21.8 
(also tried libprotoc 24.0)

on Mac OS (M1)

I thought that this wouldn't happen and got fixed by #848 or #844 but it isn't unfortunately.
I don't know if I'm missing something

Here is a sample snippet:

@$pb.GrpcServiceName('verification.VerificationService')
class VerificationServiceClient extends $grpc.Client {
...

the respective error:

lib/src/generated/proto/verification.pbgrpc.dart:22:6: Error: Couldn't find constructor 'GrpcServiceName'.
@$pb.GrpcServiceName('verification.VerificationService')
     ^^^^^^^^^^^^^^^
@wheeOs
Copy link
Author

wheeOs commented Aug 10, 2023

for the time being, is there any possibility to use an older version of protoc_plugin? I couldn't figure out how to activate the plugin globally with a specific version other than the latest.

@CaseyHillers
Copy link

I was able to work around this in my project by manually overriding from protobuf 2 to 3 by adding the following to my pubspec.yaml:

dependency_overrides:
  protobuf: ^3.0.0

@wheeOs
Copy link
Author

wheeOs commented Aug 14, 2023

@CaseyHillers thank you for sharing this! Finally a workaround.. that fixed it!

@sigurdm
Copy link
Collaborator

sigurdm commented Aug 14, 2023

@wheeOs

I couldn't figure out how to activate the plugin globally with a specific version other than the latest.

For next time:

$ dart pub global activate --help
Make a package's executables globally available.

Usage: dart pub global activate <package> [version-constraint]

So for example:

> dart pub global activate protoc_plugin 20.0.1

Will install v. 20.0.1

@wheeOs
Copy link
Author

wheeOs commented Aug 14, 2023

@sigurdm
ah ... I was trying to do it via flutter pub global activate protoc_plugin@20.0.1 instead 🤦🏻‍♂️
Thanks for pointing that out!

@sigurdm
Copy link
Collaborator

sigurdm commented Aug 14, 2023

ah ... I was trying to do it via flutter pub global activate protoc_plugin@20.0.1 instead 🤦🏻‍♂️

Yeah, that would also make sense given the new pub add syntax.

@JeromeChezExfo
Copy link

I have the exact same issue on Ubuntu 22.04.3 with libprotoc 3.12.4 and protoc_plugin 21.1.1. I also tried with protoc_plugin 20.0.1 as mentioned above but this didn't help.

How did you figure which version of protoc_plugin was compatible with libprotoc on your end?

@mw66
Copy link

mw66 commented Oct 28, 2023

Ubuntu 22.04.3

dart pub global activate protoc_plugin 20.0.1

worked for me.

@GHAMDANdev
Copy link

CaseyHillers

Thank you CaseyHillers...

I fix my issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants