Jun 2 | 8:55 AM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
CodeApprentice | has entered the room |
Mark M. |
hello, CodeApprentice!
|
Mark M. |
how can I help you today?
|
CodeApprentice |
Good morning.
|
CodeApprentice |
I'm trying to set up UI Automator 2.0 in an existing project in Android Studio 1.2.1.1.
|
CodeApprentice |
the IDE gives me "Warning:Conflict with dependency 'com.android.support:support-annotations'. Resolved versions for app (22.2.0) and test app (22.0.0) differ."
|
Bryan | has entered the room |
Bryan |
Hello
|
Mark M. |
(BTW, hello Bryan, I will be with you in a moment!)
|
Bryan |
sounds good
|
Jun 2 | 9:00 AM |
Mark M. |
CodeApprentice: what are "app" and "test app"?
|
CodeApprentice | |
CodeApprentice |
my dependencies
|
CodeApprentice |
I don't understand your question.
|
Mark M. |
your error cites "Resolved versions for app (22.2.0) and test app (22.0.0) differ."
|
Mark M. |
does the name "test app" ring any bells?
|
CodeApprentice |
no, I believe that's a generic name for the code under androidTest.
|
CodeApprentice |
I'm using the "new" gradle project structure
|
Mark M. |
ah, OK
|
Mark M. |
kinda confusing -- they should be citing something like androidTest there
|
CodeApprentice |
yah, the error message is unclear in lots of ways
|
Mark M. |
anyway, you'll probably want to run a Gradle dependency report
|
Mark M. |
gradle dependencies
|
Bill M. | has entered the room |
Mark M. |
run at the command line
|
CodeApprentice |
./gradlew :app:dependencies isn't very helpful...it gives the same error.
|
Mark M. |
(BTW, hello Bill, I will be with you in a bit, after CodeApprentice and Bryan!)
|
Mark M. |
well the dependency report should show you who is asking for what
|
Bill M. |
Yep! No problem. Thanks Mark. Hello all.
|
Mark M. |
one of your direct dependencies wants 22.2.0 of support-annotations, the other wants 22.0.0
|
Mark M. |
you need to determine who wants what, so you can add exclude directives in the Gradle build file, to eliminate the requirement for the older one, and then hope it all holds together
|
Mark M. |
or, perhaps you can raise the version of the direct dependency that is looking for 22.0.0 to something higher, one that will be happy with 22.2.0
|
CodeApprentice |
From http://stackoverflow.com/questions/29857695/and... it looks like the conflict is between the dependencies of `com.android.support.test0.2` and `com.android.support:support-v4:22.1.0`
|
Mark M. |
well, that emoji is a first for this chat... :-)
|
Jun 2 | 9:05 AM |
CodeApprentice |
and that emoji is supposed to be the word "runner"
|
Mark M. |
hah!
|
CodeApprentice |
ahh...the colon separator turned it into an emoji
|
Mark M. |
anyway, either you need to synchronize the direct dependencies, or exclude the older 22.0.0 transitive dependency and hope that the library that wanted it will be happy with 22.2.0
|
Mark M. |
let me take questions from the others, and I'll be back with you in a bit
|
Mark M. |
Bryan: your turn! do you have a question?
|
Bryan |
yes
|
Bryan |
I have 2 questions the first has to do with "Fragment already added" errors I am getting. We are doing a single activity app that manages fragment "ups" synonmous with "back". We are getting this error at "random" (meaning I can't reproduce reliably yet) times. (crash = http://pastebin.com/wzuA7xiQ). What I am confused about is that we first try to find a fragment by tag and then use that otherwise we create a new one and then we just use .replace(). How can hitting "back" add a fragment that has already been added?
|
Mark M. |
how are you creating a new one? are you sure there isn't some logic in there that tries to recycle an existing instance?
|
CodeApprentice |
sounds good. I'll be working on things on my end.
|
Bryan |
when we navigat to new ones, we do try to recycle and use replacr
|
Mark M. |
the error sure sounds like it is the existing HomeFragment instance that is trying to be added again
|
Bryan |
this only happens on back
|
Mark M. |
I don't mean your findFragmentByTag() call; are you holding onto HomeFragment anywhere?
|
Bryan |
oh, meaning a memory leak of sorts?
|
Jun 2 | 9:10 AM |
Bryan |
if so, it is very possible
|
Mark M. |
you might experiment with dump() on FragmentManager
|
Bryan |
so if I have an instance of homefragment still being held by something and we hit back, it won't "reuse" the hoemfragment in memory, but will error out because it is?
|
Bryan |
(is held in memory)
|
Mark M. |
well, I don't know all the ins and outs of your code
|
Mark M. |
anyway, back to dump()
|
Bryan |
yeah, how would you recommend using that?
|
Mark M. |
I haven't played with it, but ideally it outputs the current contents of the FragmentManager
|
Mark M. |
you might experiment with in the lab, to see whether the FragmentManager contents match your expectations
|
Bryan |
Ok, interesting, I think i will focus first on trying to reliably duplicate the error and then see what is in dump on error vs not on error
|
Mark M. |
and depending on what you are doing in production, when you catch this error, you might dump() the state and include it in some report to your server
|
Bryan |
perfect, thank you!
|
Mark M. |
let me take questions from the others, and I'll be back with you in a bit
|
Bryan |
can I wait in line for my second question?
|
Bryan |
kk
|
Mark M. |
Bill: your turn! do you have a question?
|
Bill M. |
Ready?! :)
|
Bill M. |
GCM related questions regarding Registration ID.
|
Bill M. |
Can an OS update actually reset the system token, like a factory reset?
|
Bill M. |
*Registration ID
|
Mark M. |
beats me
|
Bill M. |
lol
|
Mark M. |
outside of what you see in the GCM chapter, I know diddly-squat about GCM
|
Mark M. |
that being said, registration IDs seem to be twitchy, from what I've seen on Stack Overflow
|
Bill M. |
Alright. No worries. I'll follow up with you when I get a response from the Googles :) Reaching out to their GDEs.
|
Bill M. |
Thanks Mark.
|
Jun 2 | 9:15 AM |
Mark M. |
CodeApprentice: back to you! do you have another question?
|
CodeApprentice |
still working on this
|
Mark M. |
OK, I'll be back with you later
|
Mark M. |
Bryan: back to you! do you have another question?
|
CodeApprentice |
bill, are you working on the behavior of the back button (at the bottom of the screen) or the up/home button in the action bar?
|
Bryan |
yes, it is already in stackoverflow, should I just paste link
|
Bryan |
or paste question?
|
Mark M. |
link is probably better
|
Bryan | |
Mark M. |
you are referring to the deep-linking stuff Google has been promoting, to allow search results to drive into an app?
|
Bryan |
no
|
Bryan |
to the stuff they currently have to do deep linking, hang on I'll get link I used
|
Bryan | |
Bryan |
it is really bizarre behavior
|
Mark M. |
that's what I was referring to, actually
|
Jun 2 | 9:20 AM |
Mark M. |
not really
|
Bryan |
I have never seen the ability to open 2 distince app instances
|
Mark M. |
they are not two instances
|
Mark M. |
they are two tasks
|
Mark M. |
if I understand your question correctly, Chrome is properly launching your activity in a new task
|
Mark M. |
whereas the other browsers are not
|
Bryan |
yes
|
Mark M. |
on Android 5.x, the title bar of the overview screen is driven by the task owner, if you will, which in this case would be the browser
|
Mark M. |
but the thumbnail will be of the top-most activity in that task
|
Mark M. |
and if they didn't open the link with new-task semantics, that'll be your activity
|
Bryan |
is there a way to tell different browsers to launch in a new task or to force them to use chrome only?
|
Bryan |
for that particular link scheme
|
Mark M. |
no and no, but you can control the task stuff through manifest entries
|
Bryan |
what do you mean?
|
Bryan |
or, what specifically do you mean
|
CodeApprentice |
Whenever you are ready, here's the relevent output of my dependencies: https://gist.github.com/codeguru42/64d284f54a7d...
|
Mark M. |
I think setting the task affinity on your activity can help manage this
|
Mark M. |
(CodeApprentice: after Bryan and Bill, I'll be with you)
|
Bryan |
Ok, I can look into that, thank you
|
Mark M. |
I'll need to work out a specific recipe for this and add it to the task chapter of the book
|
Mark M. |
I had thought browser developers would always spawn these things in new tasks, if it's not being handled directly by their own app (i.e., a link to a regular Web page)
|
Mark M. |
let me take questions from the others, and I'll be back with you in a bit
|
Jun 2 | 9:25 AM |
Bryan |
I need to ready up on tasks too, I am thinking in a different paradigm
|
Jun 2 | 9:25 AM |
Bryan |
ok
|
Mark M. |
Bill: your turn! do you have another question?
|
Mark M. |
Bill: if you have another question, chime in and let me know; for the moment, I'll focus on the others
|
Mark M. |
CodeApprentice: so appcompat-v7 wants 22.2.0 of support-annotations, and runner wants 22.0.0
|
CodeApprentice |
so how do I resolve the conflict?
|
Mark M. |
change androidTestCompile 'com.android.support.test0.2' slightly
|
Mark M. |
beyond fixing the emoji
|
Mark M. |
go androidTestCompile(...) { exclude module: 'support-annotations' }
|
Mark M. |
where ... is the artifact string that gets emojified here in chat
|
Mark M. |
and "go" is just a verb I used in the not-exactly sentence there
|
Jun 2 | 9:30 AM |
Mark M. |
AFAIK you need the parentheses to allow the closure syntax
|
Mark M. |
the exclude line says "pay no attention to this transitive dependency"
|
Mark M. |
you are filling that dependency elsewhere
|
Mark M. |
now, there's a chance that this won't work, in that something in 22.2.0 breaks what runner wants from 22.0.0
|
Mark M. |
in which case, you could try excluding support-annotations from appcompat-v7, to force the older edition, but that seems even more likely to have problems
|
Mark M. |
and, if neither combination works, AFAIK, you're screwed
|
Mark M. |
which is why runner really needs to be more flexible in its dependency requirement
|
CodeApprentice |
one other option is to revert to an earlier version of appcompat-v7
|
Mark M. |
that too
|
CodeApprentice |
not ideal, but doable
|
Mark M. |
though that has other ramifications, particularly since it's a GUI bit, so the older edition won't necessarily tint all the widgets you'd like
|
Mark M. |
plus bug fixes and whatnot
|
CodeApprentice |
and btw, yes, the parens are required.
|
Mark M. |
let me take questions from the others, and I'll be back with you shortly
|
Mark M. |
Bryan: your turn! do you have another question?
|
CodeApprentice |
hmmm....still getting the same error. Maybe another of my recently added dependencies also depends on support-annotations...
|
Mark M. |
(CodeApprentice: grep through the dependency report, I guess, seeing who else wants it)
|
CodeApprentice |
working on that ;-)
|
Jun 2 | 9:35 AM |
Mark M. |
OK, it's free-for-all time -- if anyone has a question, go right ahead
|
Bryan |
what is the best way to manage apk size?
|
Mark M. |
exercise and eating right
|
Mark M. |
:-)
|
Bryan |
nice
|
Mark M. |
could you be more specific?
|
Mark M. |
I have a chapter on APK size tips in the book
|
Mark M. |
plus Cyril Mottier has http://cyrilmottier.com/2014/08/26/putting-your...
|
Mark M. |
and there's other stuff I need to add in there, like shrinkResources
|
Bryan |
perfect, I will read both of those~!
|
Mark M. |
again, if anyone has any question, go right ahead
|
Bryan |
View paste
|
Mark M. |
that doesn't restart an app
|
Jun 2 | 9:40 AM |
Bryan |
sorry, acgivity
|
Bill M. | has left the room |
Mark M. |
it shouldn't be needed
|
Mark M. |
just move your onCreate() and related code out to some other method
|
Mark M. |
that you call from onCreate() and on an authentication state change
|
Bryan |
hmmmm
|
Bryan |
that seems very simple and elegant
|
Bryan |
almost too easy
|
Mark M. |
it'll also have less UI flicker
|
Mark M. |
as we skip the activity transition
|
Bryan |
I wonder if I had issues with the pulling the drawer stuff out of the oncreate? Authenticated there is a drawer, not so with unauthenticated
|
Bryan |
i will have to take a look, thanks
|
CodeApprentice |
well, adding "exclude module: 'support-annotations'" still results in the same error. And I can't find anything in the dependencies report that shows another library with a transitive dependency.
|
Mark M. |
would it be possible for you to post the whole report to another gist or something?
|
CodeApprentice |
just support-v4 and runner depend on support-annotations
|
CodeApprentice |
yah, I can do that
|
CodeApprentice | |
CodeApprentice |
that's the one with the "exclude module"
|
Jun 2 | 9:45 AM |
Mark M. |
well, here's one possibility, rolling back to my original "app"/"test app" question
|
Mark M. |
let's assume that "app" means the actual app and "test app" is the app with the androidTest sourceset included
|
Mark M. |
your exclude stuff means that only one support-annotations will be used in each of those
|
Mark M. |
however, the error message is complaining about the difference between "app" and "test app"
|
Mark M. |
and, based on the reports, those do indeed differ
|
Mark M. |
the test apps are using 22.0.0; the app is using 22.2.0
|
Mark M. |
now, *why* the tooling would care, I can't say
|
CodeApprentice |
so are you thinking that "test app" refers to the combination of both the main app and the androidTest stuff?
|
Mark M. |
correct
|
CodeApprentice |
hmm...
|
Mark M. |
and that, for some reason, the tools want the dependencies to jive between the app and the test app
|
CodeApprentice |
I see what you mean. In other words, the error message isn't very good.
|
Mark M. |
actually, it's better than what I had been originally thinking, if my guess is correct :-)
|
Mark M. |
"test app" isn't especially clear
|
Jun 2 | 9:50 AM |
Mark M. |
now, to fix this, you'd basically need to pin the regular and test editions of each build variant to the same support-annotations version
|
Mark M. |
if nothing else, you'd exclude {} the transitive dependency from appcompat-v7 and runner, and manually require some version of support-annotations
|
Mark M. |
though there may be some simpler Gradle syntax for handling this
|
CodeApprentice |
Shouldn't excluding the support-annotations from runner be the same thing?
|
Mark M. |
um, probably
|
Mark M. |
to quote the old Infocom game Zork, "you are in a maze of twisty little passages, all alike" :-)
|
Jun 2 | 9:55 AM |
CodeApprentice |
hmm...https://code.google.com/p/android-test-ki... seems to be a bug report about this issue
|
Mark M. |
yeah, resolutionStrategy was the simpler Gradle syntax that I was thinking of
|
Mark M. |
basically, a single place to pin the version of a particular transitive dependency
|
CodeApprentice |
trying that now
|
Mark M. |
we are running out of chat time -- now's a fine time to get any last questions in!
|
Bryan |
Is there a way to get a transcript of this emailed to me?
|
Mark M. |
no, but you can view one at https://commonsware.com/office-hours/ shortly after the chat ends
|
Bryan |
ok, great, thanks!
|
CodeApprentice |
well, the resolutionStrategy worked...now to figure out the next error message.
|
Jun 2 | 10:00 AM |
Mark M. |
well, it's good to know that you're making progress
|
Mark M. |
and with that, that's a wrap for today's chat
|
CodeApprentice |
I'll bump an SO question and/or be back for the next office hours.
|
CodeApprentice |
thanks for your help!
|
Mark M. |
the next one is Thursday at 4pm US Eastern
|
Mark M. |
you are very welcome
|
Mark M. |
have a pleasant day, all!
|
CodeApprentice | has left the room |
Bryan | has left the room |
Mark M. | turned off guest access |