-
Notifications
You must be signed in to change notification settings - Fork 15.5k
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
java.lang.IllegalAccessError: class com.google.protobuf.GeneratedMessageV3 tried to access method 'boolean com.google.protobuf.CodedInputStream.shouldDiscardUnknownFields()' #19371
Comments
Could you try using a recent version of protobuf-javalite instead of protobuf-lite? |
@acozzette I tried with varied different version from protobuf-javalite. The project can't compile with following new issues. |
@zgzong I suspect that your build is still using an old version of protoc. If you regenerate your code using a protoc version that matches the protobuf-javalite version then those errors should hopefully go away. |
@acozzette
|
I think you must be somehow mixing multiple protobuf versions in the same program. |
same issue here
|
Hmm, interesting. I see a very similar error reported here as well. I wonder if this may be a bug in the way Android uses protobuf. Let me dig into this some more and see if I can figure it out. |
@zgzong @sirius60111 Are you able to reproduce this with the most recent version of Android Studio? It's possible that someone has already fixed it in the most recent version. |
@zgzong @sirius60111 Actually could you do "Help -> Submit feedback" to submit a bug report in Android Studio and reference this GitHub issue? That should help reach the owners of the affected code. |
@acozzette I run macrobenchmark test using command line |
Thanks @acozzette for linking to that issue. I followed the suggestion of someone there in upgrading Android Build Gradle plugin, and that fixed the issue for me (which I was also facing when running an Android instrumented test, same as OP). See my comment here for specifics on versions: leancodepl/patrol#2307 (comment). @zgzong, could you try upgrading your Android Build Gradle plugin? |
After upgrading the Android Gradle Plugin, the issue was resolved. |
Thanks @acozzette @bnorth-cltd for shine the light. Strange thing that I didn't see any AGP release notes mention same issue. @sirius60111 connectedXXXBenchmarkAndroidTest is same as run from gradle tasks from dropdown list. |
Yeah, I'm not sure which version of AGP fixes the issue (maybe when they upgraded a protobuf dependency?). But it's good to hear that |
What version of protobuf and what language are you using?
Version: protobuf-lite: version: 3.0.1
Language: java
What operating system (Linux, Windows, ...) and version?
Windows 11
What runtime / compiler are you using (e.g., python version or gcc version)
Running AndroidTest from Android studio v2023.3.1
What did you do?
Steps to reproduce the behavior:
What did you expect to see
The AndroidTest can be launched on connected Android device and finish AndroidTest.
What did you see instead?
SEVERE: Fatal error while executing main with args: --proto_config=C:\Users\xxx.android\utp\runnerConfig969432027192655346.pb --proto_server_config=C:\Users\xxx.android\utp\serverConfig5384709628783943825.pb
java.lang.IllegalAccessError: class com.google.protobuf.GeneratedMessageV3 tried to access method 'boolean com.google.protobuf.CodedInputStream.shouldDiscardUnknownFields()
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
Tried with connected device: Pixel Tablet, Pixel 6, 7, and 8 with varies android os.
I am rung android test with debug flavour build, which doesn't require proGuard/R8. Anyway, the following trick doesn't works for me.
-keep class com.google.protobuf.** {*;}
-keepclassmembers class * extends com.google.protobuf.GeneratedMessageLite {
;
}
-keepclassmembers class * extends com.google.protobuf.GeneratedMessageV3 {
;
}
The text was updated successfully, but these errors were encountered: