Skip to content

java.lang.NoClassDefFoundError: java.nio.charset.StandardCharsets in Android API < 19 #604

@cokeperez

Description

@cokeperez

Hi,

we have problems with the latest version of your library in devices running Android 4.3 (API 18) or lower. StandardCharsets was added in Android API 19 so any call to methods using that (for example, StringUtils.getBytesUtf8 or StringUtils.newStringUtf8) causes a crash in our app.

Environment details

  • OS: Android API < 19
  • google-http-java-client version: 1.28

Stacktrace

    java.lang.NoClassDefFoundError: java.nio.charset.StandardCharsets
        at com.google.api.client.util.StringUtils.getBytesUtf8(StringUtils.java:52)
        at com.google.api.client.json.webtoken.JsonWebSignature.signUsingRsaSha256(JsonWebSignature.java:636)
        at com.google.api.client.googleapis.auth.oauth2.GoogleCredential.executeRefreshToken(GoogleCredential.java:388)
        at com.google.api.client.auth.oauth2.Credential.refreshToken(Credential.java:494)
        at com.google.api.client.auth.oauth2.Credential.intercept(Credential.java:217)
        at com.google.api.client.googleapis.batch.BatchRequest$BatchInterceptor.intercept(BatchRequest.java:281)
        at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:911)
        at com.google.api.client.googleapis.batch.BatchRequest.execute(BatchRequest.java:233)
        at our.app.PubSubManager.sendTopic(PubSubManager.java:100)
        at java.lang.Thread.run(Thread.java:841)

Any additional information below

https://developer.android.com/reference/java/nio/charset/StandardCharsets.html

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions