Skip to content
This repository was archived by the owner on Jan 13, 2021. It is now read-only.

ClassCastException #44

Closed
D3SOX opened this issue Aug 24, 2018 · 12 comments
Closed

ClassCastException #44

D3SOX opened this issue Aug 24, 2018 · 12 comments
Assignees
Labels

Comments

@D3SOX
Copy link

D3SOX commented Aug 24, 2018

/usr/lib/jvm/java-8-jdk/bin/java
Exception in thread "main" java.lang.ClassCastException: com.google.gson.internal.LinkedTreeMap cannot be cast to com.github.felixgail.gplaymusic.model.DeviceInfo
at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:174)
at java.util.ArrayList$ArrayListSpliterator.tryAdvance(ArrayList.java:1359)
at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)
at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:498)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464)
at com.github.felixgail.gplaymusic.api.GPlayMusic$Builder.build(GPlayMusic.java:393)

AuthToken authToken = TokenProvider.provideToken(username, password, androidId);
this.musicApi = new GPlayMusic.Builder().setAuthToken(this.authToken).build();
@FelixGail
Copy link
Owner

This seems to be linked to #40. I am still not sure why gson is returning a LinkedTreeMap instead of (in this case) DeviceInfo. What Java and Project version are you using?

@D3SOX
Copy link
Author

D3SOX commented Aug 24, 2018

JDK 1.8.0_181 and API version 0.3.5

@FelixGail
Copy link
Owner

Very odd. I am using the same jdk and api version and i can not recreate this issue

@D3SOX
Copy link
Author

D3SOX commented Aug 24, 2018

I found out the source of the problem.
When i have this also in my dependencies it does not work otherwise it works

    <dependency>
        <groupId>se.michaelthelin.spotify</groupId>
        <artifactId>spotify-web-api-java</artifactId>
        <version>2.0.4</version>
    </dependency>

@FelixGail
Copy link
Owner

Interesting. This means there are different gson versions. One of them seems to not work with my api. Let me have a look at that

@FelixGail FelixGail self-assigned this Aug 24, 2018
@FelixGail FelixGail added the bug label Aug 24, 2018
@FelixGail
Copy link
Owner

I can confirm that the problem is with the current gson version. I am currently really short on time so it may take a while to adapt the project.
For the meantime I defined which version of gson should be used. Could you try if gplaymusic:0.3.6-R0-SNAPSHOTworks for you?

@D3SOX
Copy link
Author

D3SOX commented Aug 24, 2018

From where can I grab this version? https://i.imgur.com/agJ9xpw.png

@FelixGail
Copy link
Owner

You need to allow snapshots. Have a look at this stackoverflow answer.

@D3SOX
Copy link
Author

D3SOX commented Aug 24, 2018

Does not work, same error

@D3SOX
Copy link
Author

D3SOX commented Aug 25, 2018

Any update?

@FelixGail
Copy link
Owner

FelixGail commented Aug 28, 2018

If i can't force maven to use the defined version if a newer one is in use - i have to update the whole project to the new gson version. I am currently working on my bachelor thesis and don't have the time to make major changes, so this could take a while :(

You could try to add

<dependency>
  <groupId>com.google.code.gson</groupId>
  <artifactId>gson</artifactId>
  <version>2.7</version>
</dependency>

to your pom.xml and see if your spotify dependency can cope with gson:2.7

@D3SOX
Copy link
Author

D3SOX commented Aug 29, 2018

Funktioniert perfekt, danke! ^^

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants