Open zgzong opened 6 days ago
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 These compile error does go after align the protoc version with protobuf-javalite. When use protoc & protobuf-javalite with 3.25.5, or 4.28.3 the original issue occurs.
java.lang.IllegalAccessError: class com.google.protobuf.GeneratedMessageV3 tried to access method 'boolean com.google.protobuf.CodedInputStream.shouldDiscardUnknownFields()' (com.google.protobuf.GeneratedMessageV3 is in unnamed module of loader java.net.URLClassLoader @4cd1c1dc; com.google.protobuf.CodedInputStream is in unnamed module of loader 'app') at com.google.protobuf.GeneratedMessageV3.parseUnknownField(GeneratedMessageV3.java:317) at com.android.server.adb.protos.AppProcessesProto$ProcessEntry.<init>(AppProcessesProto.java:119) at com.android.server.adb.protos.AppProcessesProto$ProcessEntry.<init>(AppProcessesProto.java:54) at com.android.server.adb.protos.AppProcessesProto$ProcessEntry$1.parsePartialFrom(AppProcessesProto.java:778) at com.android.server.adb.protos.AppProcessesProto$ProcessEntry$1.parsePartialFrom(AppProcessesProto.java:772) at com.google.protobuf.CodedInputStream$ArrayDecoder.readMessage(CodedInputStream.java:980) at com.android.server.adb.protos.AppProcessesProto$AppProcesses.<init>(AppProcessesProto.java:879) at com.android.server.adb.protos.AppProcessesProto$AppProcesses.<init>(AppProcessesProto.java:829) at com.android.server.adb.protos.AppProcessesProto$AppProcesses$1.parsePartialFrom(AppProcessesProto.java:1571) at com.android.server.adb.protos.AppProcessesProto$AppProcesses$1.parsePartialFrom(AppProcessesProto.java:1565) at com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:111) at com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:126) at com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:20) at com.android.server.adb.protos.AppProcessesProto$AppProcesses.parseFrom(AppProcessesProto.java:1027) at com.android.ddmlib.internal.DeviceClientMonitorTask$TrackAppProcessor.onMessage(DeviceClientMonitorTask.java:585) at com.android.ddmlib.internal.DeviceClientMonitorTask$Processor.onBytesReceived(DeviceClientMonitorTask.java:501) at com.android.ddmlib.internal.DeviceClientMonitorTask.run(DeviceClientMonitorTask.java:281) at java.base/java.lang.Thread.run(Thread.java:840)
I think you must be somehow mixing multiple protobuf versions in the same program.
same issue here I use Jetpack macrobenchmark testing my app It works fine when I connect and test on an Android 13 device, but when I switch to an Android 15 device, this IllegalAccessError came out
Nov 27, 2024 5:41:13 PM com.android.tools.utp.plugins.host.apkinstaller.AndroidTestApkInstallerPlugin configure
INFO: No installables found in test fixture. Nothing to install.
Nov 27, 2024 5:41:13 PM com.google.testing.platform.plugin.android.AndroidDevicePlugin configure
INFO: No installables found in test fixture. Nothing to install.
Nov 27, 2024 5:41:13 PM com.google.testing.platform.main.MainKt$main$2 uncaughtException
SEVERE: Fatal error while executing main with args: --proto_config=/home/mi/.android/utp/runnerConfig7828165919515485024.pb --proto_server_config=/home/mi/.android/utp/serverConfig1928644563722895952.pb
java.lang.IllegalAccessError: class com.google.protobuf.GeneratedMessageV3 tried to access method 'boolean com.google.protobuf.CodedInputStream.shouldDiscardUnknownFields()' (com.google.protobuf.GeneratedMessageV3 is in unnamed module of loader java.net.URLClassLoader @4b4bfb48; com.google.protobuf.CodedInputStream is in unnamed module of loader 'app')
at com.google.protobuf.GeneratedMessageV3.parseUnknownField(GeneratedMessageV3.java:317)
at com.android.server.adb.protos.AppProcessesProto$ProcessEntry.<init>(AppProcessesProto.java:119)
at com.android.server.adb.protos.AppProcessesProto$ProcessEntry.<init>(AppProcessesProto.java:54)
at com.android.server.adb.protos.AppProcessesProto$ProcessEntry$1.parsePartialFrom(AppProcessesProto.java:778)
at com.android.server.adb.protos.AppProcessesProto$ProcessEntry$1.parsePartialFrom(AppProcessesProto.java:772)
at com.google.protobuf.CodedInputStream$ArrayDecoder.readMessage(CodedInputStream.java:980)
at com.android.server.adb.protos.AppProcessesProto$AppProcesses.<init>(AppProcessesProto.java:879)
at com.android.server.adb.protos.AppProcessesProto$AppProcesses.<init>(AppProcessesProto.java:829)
at com.android.server.adb.protos.AppProcessesProto$AppProcesses$1.parsePartialFrom(AppProcessesProto.java:1571)
at com.android.server.adb.protos.AppProcessesProto$AppProcesses$1.parsePartialFrom(AppProcessesProto.java:1565)
at com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:111)
at com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:126)
at com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:20)
at com.android.server.adb.protos.AppProcessesProto$AppProcesses.parseFrom(AppProcessesProto.java:1027)
at com.android.ddmlib.internal.DeviceClientMonitorTask$TrackAppProcessor.onMessage(DeviceClientMonitorTask.java:585)
at com.android.ddmlib.internal.DeviceClientMonitorTask$Processor.onBytesReceived(DeviceClientMonitorTask.java:501)
at com.android.ddmlib.internal.DeviceClientMonitorTask.run(DeviceClientMonitorTask.java:281)
at java.base/java.lang.Thread.run(Thread.java:898)
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.
@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.
@acozzette I run macrobenchmark test using command line
./gradlew --daemon clean :benchmark:connectedXXXBenchmarkAndroidTest
not click run button in Android Studio
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.
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: https://github.com/leancodepl/patrol/issues/2307#issuecomment-2507133537.
@zgzong, could you try upgrading your Android Build Gradle plugin?
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 {