Dec 26 | 3:50 PM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
Dec 26 | 4:00 PM |
Mike | has entered the room |
Mark M. |
hello, Mike!
|
Mark M. |
how can I help you today?
|
Mike |
Hi Mark. Hope you are doing well. I am working on a sample app with Retrofit, and there is a line of code that I am having trouble with. I have it on Google Drive, can I paste a link, or is there a diffferent way that you would prefer to look at it. It is 5 files.
|
Mark M. |
um, well, are you comfortable with the world seeing the files? or at least the portion of the world that stumbles upon this chat transcript?
|
Mike |
no problem, I can remove them when we are done. would that work?
|
Dec 26 | 4:05 PM |
Mark M. |
it's more that since I archive these transcripts, I kinda like them to still be useful in the future, to the extent possible
|
Mark M. |
that's a problem for larger dumps of code, since the links will stop working
|
Mark M. |
can you paste in the line that is giving you trouble as a starting point?
|
Mike |
Sure.
|
Mark M. |
then, we can determine what else (if anything) I'll need to see to make sense of the problem
|
Mike |
should I paste or use the "upload a file" link?
|
Mark M. |
for a single line? just paste it into the chat message textarea
|
Mike |
ok, let's start with that:
|
Mike |
call.enqueue (new Callback<WeatherResults>()) {
|
Mike |
The issue is that enqueue is unresolved
|
Mark M. |
what is the "call" object?
|
Mike |
View paste
|
Mike |
these lines seem ok
|
Mark M. |
what version of Retrofit are you using?
|
Mark M. |
because Retrofit 2.x definitely has enqueue() on Call: http://square.github.io/retrofit/2.x/retrofit/
|
Dec 26 | 4:10 PM |
Mike |
2
|
Dec 26 | 4:10 PM |
Mark M. |
on WeatherClient, are you sure that you are importing retrofit2.Call and not some other Call class?
|
Mark M. |
and are you sure that your Callback is a retrofit2.Callback and not some other Callback class?
|
Mike |
Yes, I have several other sample apps loaded in AS from you and other sources, and I have been carefully comparing what I am doing to what others do with Retrofit, as I can't seem to see why it doesn't like it
|
Mike |
In the other apps, they have no problem with the enqueue
|
Mark M. |
OK, in Android Studio, start entering a new line of code before the call.enqueue() that is giving you the error
|
Mark M. |
type in call., then wait for autocomplete
|
Mark M. |
is enqueue() an option in the autocomplete?
|
Mike |
Yes, that seems to work.
|
Mark M. |
OK, so you definitely have the right Call class
|
Mark M. |
now, let it autocomplete enqueue, then inside the parentheses, start typing new Callback, until you get an autocomplete to define that
|
Dec 26 | 4:15 PM |
Mark M. |
let the autocomplete build the Callback anonymous inner class for you
|
Mark M. |
and then compare and contrast that enqueue() with the one that the IDE doesn't like
|
Mike |
well...
|
Mike |
i do notice that when
|
Mike |
I type call. in another app, I get all of the suggestions, but I don't get any in my app
|
Mark M. |
I must have misunderstood -- I thought that you said it worked
|
Mike |
oops, i misread your request. No, I don't get the autocomplete in my app, sorry.
|
Mark M. |
is it that you are not getting any autocomplete, or that autocomplete does not have enqueue() in it?
|
Dec 26 | 4:20 PM |
Mike |
i get none
|
Mark M. |
and you're sure that this call object is in scope at this line?
|
Mark M. |
for example, if you have Call<WeatherResults> call = client.weatherReturned("09105"); in some other method, that's a problem
|
Mark M. |
if it helps, at this point, feel free to upload this particular file using the "upload a file" option, or just paste the whole thing into the textarea
|
Mark M. |
(there's enough context here for people who run across this chat transcript)
|
Dec 26 | 4:25 PM |
Mike |
Would it be OK to upload a zip of my app for you to look at in AS?
|
Mike |
wait, sorry, i didn't see your response, stand by while i read
|
Mark M. |
is it OK if I just sit by? I can stand if needed... :-)
|
Mike |
lol
|
Mike |
ok, i will paste in the file...
|
Dec 26 | 4:30 PM |
Mike |
View paste
(33 more lines)
|
Mark M. |
OK
|
Mark M. |
you have an onCreate method
|
Mark M. |
you then have a whole bunch of code that is not in any method
|
Mark M. |
that code belongs in a method somewhere
|
Mark M. |
the reason why the first few lines aren't generating errors is that the IDE thinks that they are field initializers
|
Mike |
oh, wow, let me take a look
|
Mike |
dumb mistake, that's what I get for copying code from different places!
|
Mark M. |
for example, if you want that code to run when the activity is created, move it inside the closing } of the onCreate() method
|
Dec 26 | 4:35 PM |
Mike |
I think that is probably what i want, but I want to mull over the whole a little more. Thanks so much for your help!
|
Mark M. |
you're very welcome!
|
Mike |
I think that is all I need right now. Have a great rest of the day.
|
Mark M. |
you too!
|
Dec 26 | 4:50 PM |
Mike | has left the room |
Dec 26 | 4:55 PM |
Mark M. | turned off guest access |