java.lang.NoSuchMethodError with GSON parseString

See original GitHub issue

I saw issue #224 and I tried the solution in there, and that did not work. I invalidated/restarted my IntelliJ cache, I tried to remove the GSON library I was using and used the one that the JAR downloaded when I put it into my build.gradle, nothing seems to have worked.

I am using v6.5.4 as that is the last version (that I’m aware of) that is compiled with Java 8.

Here is where the problem is:

    AuthorizationCodePKCERequest authorizationCodePKCERequest = api.authorizationCodePKCE(code, VERIFIER).build();
    try {
      AuthorizationCodeCredentials credentials = authorizationCodePKCERequest.execute();

After I run .execute() it throws an exception:

Exception in thread "Thread-15" java.lang.NoSuchMethodError: com.google.gson.JsonParser.parseString(Ljava/lang/String;)Lcom/google/gson/JsonElement;
	at com.wrapper.spotify.SpotifyHttpManager.getResponseBody(SpotifyHttpManager.java:296)
	at com.wrapper.spotify.SpotifyHttpManager.post(SpotifyHttpManager.java:183)
	at com.wrapper.spotify.requests.AbstractRequest.postJson(AbstractRequest.java:123)
	at com.wrapper.spotify.requests.authorization.authorization_code.pkce.AuthorizationCodePKCERequest.execute(AuthorizationCodePKCERequest.java:37)

Which I find weird, because when opening it up in IntelliJ Ctrl + Click, it… doesn’t have any errors? And Ctrl + Clicking parseString brings me to the method it otherwise could not find?

image

The request works fine, as I did some testing before trying to get the authorization codes and the callback worked fine, and I was able to get the code + the window opens to authorize with my application.

Any pointers? I’m genuinely confused and I’m entirely lost.

Edit: Proof that I can get the code just fine: image

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Sxmuraicommented, May 9, 2022

I tried what I suggested, and that did not work either.

I thank you for trying to help me though! I’ll keep this issue open in case I find a fix, unless you’d like to close it.

0reactions
Sxmuraicommented, May 16, 2022

So update on this, I recently upgraded to Java 17 and it seems to work now, thanks for all of the help. It just seems like for some reason it didn’t like java 8

Read more comments on GitHub >

github_iconTop Results From Across the Web

0 - Stack Overflow
I'm trying to use Unirest in my program but I keep getting this error java.lang.NoSuchMethodError: com.google.gson.Gson.
Read more >
Issues - GitHub
Pact publish & verify failing with java.lang.NoSuchMethodError: com.google.gson.JsonParser.parseString(Ljava/lang/String;)Lcom/google/gson/JsonElement #1077.
Read more >
Solved - GSON JsonParser#parseReader() NoSuchMethodError
Hello there, so currently i'm running into a Problem where i can't get Gson to run correctly. I am calling an API, and...
Read more >
JsonParser - gson 2.10 javadoc
Use parseString(java.lang.String). static JsonElement. parseReader(JsonReader reader). Returns the next value from the JSON stream as a parse tree.
Read more >
Troubleshooting SDK Java | SAP Cloud SDK
In your application log you find exception java.lang.NoSuchMethodError: com.google.gson.JsonParser.parseReader(Lcom/google/gson/stream/JsonReader ...
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