googleapis / googleapis/google-http-java-client
java.lang.NoClassDefFoundError: java.nio.charset.StandardCharsets in Android API < 19
- 主要語言
- Java
- 星號
- 1.4k
- 分支
- 473
- PR 合併指標
- 30 天內沒有已合併 PR
描述
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!
貢獻指南
研究方向
從 StringUtils.java 開始,特別檢查 getBytesUtf8 和 newStringUtf8;堆疊追蹤指出它們在 Android API <19 上失敗。在受影響的 API 層級重現當機,並追蹤 JsonWebSignature.java 和 GoogleCredential.java 中顯示的呼叫端。當這些 UTF-8 操作不再於 API 18 及以下版本載入無法使用的 StandardCharsets 類別時,即表示完成。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- android, java
- 領域
- mobile-dev
- Issue 類型
- 缺陷
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 42/100