Api 19 Caused by: java.lang.NoClassDefFoundError: java.nio.charset.StandardCharsets
See original GitHub issueEnvironment details
- OS type and version: Android api 19
- Java version: 8
- google-http-client version(s): implementation ‘com.google.http-client:google-http-client-gson:1.34.0’
Code example
private static List<File> exeQ(String q) throws IOException { String nextPageToken = “”; List<File> res = new ArrayList<>(); do { final FileList list = googleDriveService.files().list().setSpaces(“drive”).setQ(q).setPageToken(nextPageToken).setFields(“nextPageToken, files(*)”).setPageSize(100).setOrderBy(“modifiedTime”).execute(); nextPageToken = list.getNextPageToken(); res.addAll(list.getFiles()); } while (nextPageToken != null); return res; }
Stack trace
Caused by: java.lang.NoClassDefFoundError: java.nio.charset.StandardCharsets
at com.google.api.client.util.escape.CharEscapers.decodeUriPath(CharEscapers.java:110)
at com.google.api.client.http.GenericUrl.toPathParts(GenericUrl.java:594)
at com.google.api.client.http.GenericUrl.<init>(GenericUrl.java:200)
at com.google.api.client.http.GenericUrl.<init>(GenericUrl.java:177)
at com.google.api.client.http.GenericUrl.<init>(GenericUrl.java:126)
at com.google.api.client.http.GenericUrl.<init>(GenericUrl.java:109)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.buildHttpRequestUrl(AbstractGoogleClientRequest.java:388)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.buildHttpRequest(AbstractGoogleClientRequest.java:423)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:542)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:475)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:592)
(GFile.java:192)
Thanks!
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
java.nio.charset.StandardCharsets - Stack Overflow
String) throws java.io.UnsupportedEncodingException; public byte[] getBytes(java.nio.charset.Charset); public byte[] getBytes();.
Read more >java.nio.charset.StandardCharsets at org.mozilla.gecko.sync ...
Caused by the new atomic uploads (see Bug 1253111). java.nio.charset.StandardCharsets is API19+, so devices below that are crashing when trying to sync.
Read more >java.nio.charset.StandardCharsets — Bitbucket - IJabz
java.lang.NoClassDefFoundError: java.nio.charset.StandardCharsets. Create issue. Issue #88 invalid.
Read more >StandardCharsets - Android Developers
Constant definitions for the standard Charsets . These charsets are guaranteed to be available on every implementation of the Java platform. See also:....
Read more >java.lang.NoClassDefFoundError: javax/activation/FileTypeMap
import java.nio.file.Path;. import java.nio.charset.StandardCharsets;. Path tempFile = Files.createTempFile("test", ".json");.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

2 weeks ago I was able to use this API on Android 4.2, but now I get this error. Is this API no longer supporting API below 19?
It seems the library does not support Android before 4.4 only because of this charset class missing that was added in API 19 which only an UTF8 name?
Anyway I reverted to version 1.33.0 of httpclient and version 1.30.1 of apiclient and “all is good” now and it appears to be working on all Android 4.x. Is that correct assumption?
Wouldn’t it be possible to include the minimum SDK in the library so we get a warning if we target a lower SDK? Other libraries are doing so and it could avoid bad surprises in production.