We hit a runtime crash using wire-grpc-server in an Android app that exposes a gRPC server on Android 6 / SDK 23.
Dependencies:
com.squareup.wire:wire-gradle-plugin / wire-runtime: 5.4.0
com.squareup.wiregrpcserver:server / server-generator: 1.0.0-alpha04
com.squareup.okio:okio: 3.9.0
- Kotlin:
2.0.21
- AGP:
8.11.2
- minSdk:
23
The generated *WireGrpc.kt contains:
val bytes = java.util.Base64.getDecoder().decode(str)
On Android 6 / SDK 23, java.util.Base64 is unavailable, so the server crashes when binding the service:
NoClassDefFoundError: Failed resolution of: Ljava/util/Base64;
at ...AppNameServerWireGrpc.descriptorFor(...)
at ...AppNameServerWireGrpc$AppNameServerImplBase.bindService(...)
This looks similar to square/wire#3127, but in this case the java.util.Base64 usage is emitted by the wire-grpc-server generator for server descriptors.
We can work around it by enabling Android core library desugaring. Would you consider either avoiding java.util.Base64 in generated Android-compatible server code, or documenting that server users with minSdk < 26 need coreLibraryDesugaring?
One possible alternative is Okio's Base64 support, for example String.decodeBase64(), since Okio is already part of the Wire stack.
We hit a runtime crash using
wire-grpc-serverin an Android app that exposes a gRPC server on Android 6 / SDK 23.Dependencies:
com.squareup.wire:wire-gradle-plugin/wire-runtime:5.4.0com.squareup.wiregrpcserver:server/server-generator:1.0.0-alpha04com.squareup.okio:okio:3.9.02.0.218.11.223The generated
*WireGrpc.ktcontains:On Android 6 / SDK 23,
java.util.Base64is unavailable, so the server crashes when binding the service:This looks similar to square/wire#3127, but in this case the
java.util.Base64usage is emitted by thewire-grpc-servergenerator for server descriptors.We can work around it by enabling Android core library desugaring. Would you consider either avoiding
java.util.Base64in generated Android-compatible server code, or documenting that server users with minSdk < 26 needcoreLibraryDesugaring?One possible alternative is Okio's Base64 support, for example
String.decodeBase64(), since Okio is already part of the Wire stack.