Skip to content

Android API 23 crash: generated server descriptor uses java.util.Base64 #12

Description

@denis-bezrukov

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions