question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Api 19 Caused by: java.lang.NoClassDefFoundError: java.nio.charset.StandardCharsets

See original GitHub issue

Environment details

  1. OS type and version: Android api 19
  2. Java version: 8
  3. 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:closed
  • Created 4 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
3c71commented, Mar 20, 2020

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?

1reaction
3c71commented, Mar 31, 2020

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found