-
-
Notifications
You must be signed in to change notification settings - Fork 136
Attempt to invoke virtual method 'java.lang.String java.lang.Package.getName()' - from Retrofit generating implementations from interfaces #528
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hey @NathanWalker, if I understand correctly, you have a Java Interface residing in whatever package in your Java files, and attempt to pass it on to If I were to translate the example library that you linked to in NS with JavaScript syntax, I would describe the interface in Java, and build the implementation by specifying the full class name to the interface, like so: function init(httpExec, cbExec) {
...
return restAdapter.create(kaaes.spotify.webapi.android.SpotifyService.class);
} As for #501 - it's unrelated to this issue - it will allow you to implement interfaces manually (versus what the aforementioned Let us know if the above helped you move forward, if not - a small repo with your specific case could assist us in better understanding the issue. |
Hi @Pip3r4o thanks for response. I am referencing as you mention like this:
Then using that in my implementation:
But that unfortunately fails :( Lemme know if you have any other ideas I could try, much appreciated!
To run the android demo, then when main screen launches, click on the search icon in top right to show search page, then login to spotify on that page (not on the main page). |
@NathanWalker, after tinkering for a bit I concluded that we var iface = SpotifyService.class; // console.log(iface) will output 'interface kaaes.spotify.webapi.android.SpotifyService' Edit: after probing some more I noticed that RestAdapter.create() call crashes every single time with the same error, no matter what interface is passed along (with NSHashCodeProvider being an exception). Will continue to investigate and let you know if anything comes up. |
@Pip3r4o does this mean I need to wait for support? Or are you suggesting downgrading Retrofit? |
@NathanWalker please read my updated comment above |
@Pip3r4o thank you so much for your help on this one!! Really tricky. Would love to see this working 👍 |
@Pip3r4o Curious if any other workarounds have been found here? |
@NathanWalker have you considered updating the |
Adding more information. The original reported error is due to this line. In short, we make an assumption that the type is declared inside a package. This is a good assumption and I think supporting fully-qualified types only is a reasonable limitation of the runtime. If this is a critical scenario then we can think of some workarounds and deal with the trade offs. I would like to hear more about it. Otherwise providing a better error handling for this error will be helpful. |
Closing this issue until further need. |
I ran into the same problem while trying to use the twitter-android-kit the app always crashed when i tried using any of the following Source i even tried extending their api client and writing my services and using a full package name . The only work around for me was creating my own http calls 😐 |
@Pip3r4o ☝️☝️ |
any fix available for this.. |
Curious if this is currently supported. I have tried many different things but none seem to work.
The issue seems to stem from the fact that the Retrofit (http://square.github.io/retrofit/) library generates implementations from interfaces and relies on the ability to take say an interface file (for example):
And generate an implementation by doing this
restAdapter.create(SpotifyService.class)
which crashes immediately with:The library I'm trying to use does this here:
https://github.com/kaaes/spotify-web-api-android/blob/master/spotify-api/src/main/java/kaaes/spotify/webapi/android/SpotifyApi.java#L69
Is there a way to make this work currently or is support for this planned and if so, it would be much appreciated to know approximately when?
UPDATE:
I found this #501, curious if it's related and if that PR which is now merged will make something like the above possible with 2.2.0?
/cc @bradmartin
The text was updated successfully, but these errors were encountered: