googleapis / googleapis/google-http-java-client

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

Open
#604 1 comment 3 reactions 0 assignees View on GitHub
type: feature request
Dominant language
Java
Stars
1.4k
Forks
473
PR merge metrics
No merged PRs in 30d

Description

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!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.