-
Notifications
You must be signed in to change notification settings - Fork 15.6k
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
NoSuchMethodError: No virtual method shouldDiscardUnknownFields #8956
Comments
Is this an android app? and are you using the lite runtime? JsonFormat is only available for non-lite runtimes, because we do not have descriptors available in the lite runtime for performance reasons. |
I am not using the lite runtime |
OK, assuming this is an android project. Are you using any tooling like ProGuard to do binary stripping? EDIT: Can confirm this method does exist in 3.17.x release branch -- https://github.com/protocolbuffers/protobuf/blob/3.17.x/java/core/src/main/java/com/google/protobuf/CodedInputStream.java#L446 |
Yes this is an android project, and it is using ProGuard. |
OK, that's an important detail :) You'll need to configure ProGuard to ensure that it does not erase aspects of the Protobuf Runtime. I'm unsure what the exact configuration should be, but hunting around online you'll be able to find solutions: I'm going to close this for now, please ping if you have additional issues. |
I have tried a couple of updates to the ProGuard configuration without luck. I did also try it with minification off and I still get the same error. I should also mention that my app has been working, it is only now showing this error after updating the android gradle plugin version and the protobuf gradle plugin version. If I downgrade, it works fine. |
Interesting, I would suggest reaching out the protobuf-gradle-plugin folks, we're not involved in that. |
Ok I will do that. Thanks for your help |
What version of protobuf and what language are you using?
Java and Java Utils Version 3.17.3
Android gradle plugin: com.google.protobuf:protobuf-gradle-plugin:0.8.17
What operating system (Linux, Windows, ...) and version?
Android
What runtime / compiler are you using (e.g., python version or gcc version)
gcc
What did you do?
This error happens when trying to convert json into a protobuf
JsonFormat.parser().merge(jsonString, builder)
What did you expect to see
No Error
What did you see instead?
java.lang.NoSuchMethodError: No virtual method shouldDiscardUnknownFields()Z in class Lcom/google/protobuf/CodedInputStream; or its super classes (declaration of 'com.google.protobuf.CodedInputStream' appears in /data/app/com.acst.android.integratedtests-aBjTJTaWJ5dUqf2RXITKng==/base.apk) at com.google.protobuf.GeneratedMessageV3$ExtendableMessage.parseUnknownField(GeneratedMessageV3.java:1133) at com.google.protobuf.DescriptorProtos$ServiceOptions.<init>(DescriptorProtos.java:34316) at com.google.protobuf.DescriptorProtos$ServiceOptions.<init>(DescriptorProtos.java:34256) at com.google.protobuf.DescriptorProtos$ServiceOptions$1.parsePartialFrom(DescriptorProtos.java:35280) at com.google.protobuf.DescriptorProtos$ServiceOptions$1.parsePartialFrom(DescriptorProtos.java:35274) at com.google.protobuf.CodedInputStream.readMessage(CodedInputStream.java:497) at com.google.protobuf.DescriptorProtos$ServiceDescriptorProto.<init>(DescriptorProtos.java:19025) at com.google.protobuf.DescriptorProtos$ServiceDescriptorProto.<init>(DescriptorProtos.java:18960) at com.google.protobuf.DescriptorProtos$ServiceDescriptorProto$1.parsePartialFrom(DescriptorProtos.java:20089) at com.google.protobuf.DescriptorProtos$ServiceDescriptorProto$1.parsePartialFrom(DescriptorProtos.java:20083) at com.google.protobuf.CodedInputStream.readMessage(CodedInputStream.java:497) at com.google.protobuf.DescriptorProtos$FileDescriptorProto.<init>(DescriptorProtos.java:1299) at com.google.protobuf.DescriptorProtos$FileDescriptorProto.<init>(DescriptorProtos.java:1201) at com.google.protobuf.DescriptorProtos$FileDescriptorProto$1.parsePartialFrom(DescriptorProtos.java:4888) at com.google.protobuf.DescriptorProtos$FileDescriptorProto$1.parsePartialFrom(DescriptorProtos.java:4882) at com.google.protobuf.AbstractParser.parsePartialFrom(AbstractParser.java:139) at com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:173) at com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:185) at com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:190) at com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:49) at com.google.protobuf.DescriptorProtos$FileDescriptorProto.parseFrom(DescriptorProtos.java:2297) at com.google.protobuf.Descriptors$FileDescriptor.internalBuildGeneratedFileFrom(Descriptors.java:410) at com.acst.overwatch.OverwatchClass.<clinit>(OverwatchClass.java:1582) at com.acst.overwatch.AvailableVirtualCheckIns$Builder.getDescriptorForType(AvailableVirtualCheckIns.java:560) at com.google.protobuf.util.JsonFormat$ParserImpl.merge(JsonFormat.java:1451) at com.google.protobuf.util.JsonFormat$ParserImpl.merge(JsonFormat.java:1338) at com.google.protobuf.util.JsonFormat$Parser.merge(JsonFormat.java:476) at com.acst.android.sharedtestresources.utils.ProtobufUtil.json2Proto(ProtobufUtil.kt:13)
Make sure you include information that can help us debug (full error message, exception listing, stack trace, logs).
Anything else we should know about your project / environment
The text was updated successfully, but these errors were encountered: