Mar 6 | 3:50 PM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
Mar 6 | 4:00 PM |
Scott W. | has entered the room |
Scott W. |
Hello
|
Mark M. |
hello Scott!
|
Mark M. |
how can I help you today?
|
Scott W. |
I've got one little problem with my AWS maven repo
|
Scott W. |
My library has 7 modules
|
Scott W. |
one of these modules is the main entry point to the library. hlsdk is the name of that module
|
Scott W. |
hlsdk uses the other 6 modules.
|
Scott W. |
the app that uses the library needs to use the hlsdk module + one of the modules hlsdk uses.
|
Scott W. |
this other module is called "camera"
|
Scott W. |
so I tried declaring the "camera" dependency in "hlsdk" with the api key-word
|
Scott W. |
instead of implementation
|
Mark M. |
that sounds about right
|
Scott W. |
it did not work
|
sudokai | has entered the room |
Mark M. |
what specifically did not work, and did you publish the updated POM to your repository before trying what did not work?
|
Mark M. |
(BTW, hello sudokai -- I will be with you shortly!)
|
Mar 6 | 4:05 PM |
Scott W. |
My intention was to publish the updated POM. I completely cleared out my S3 bucket and used the publish task again after I made the change.
|
Scott W. |
but I don't know how to verify that api was used.
|
Mark M. |
did you look at the POM itself? the entry for that dependency should look a bit different
|
Scott W. |
I'll look now. It might take me a few minutes.
|
Mark M. |
OK, let me take a question from sudokai in the meantime, and I will be back with you in a bit
|
Mark M. |
sudokai: hi! how can I help you today?
|
sudokai |
Hi
|
sudokai |
I have thought of the question yet
|
Scott W. |
the "camera" dependency has scope = compile
|
Scott W. |
my other dependencies have scope = runtime
|
Mar 6 | 4:10 PM |
Mark M. |
that all fits what I would expect
|
Mark M. |
did you bump the version number of the artifact when making this change?
|
Mark M. |
(sudokai: if you come up with a question, let me know!)
|
Mark M. |
Scott: because otherwise, Gradle will keep using the copy of the AAR and POM located in your Gradle cache (e.g., ~/.gradle on macOS and Linux)
|
Mark M. |
unless you use --refresh-dependencies or something to force Gradle to reload
|
Scott W. |
I did not bump
|
Scott W. |
android studio has a "clean cache and restart" button
|
Mark M. |
yeah, that's a different cache, so I don't know if that will help
|
Scott W. |
ok
|
Mark M. |
frankly, I have never found a way to force the dependencies to refresh from inside the IDE, though I have not looked recently
|
Mark M. |
a command-line build would use --refresh-dependencies (e.g., ./gradlew --refresh-dependencies demo:assembleDebug)
|
Mark M. |
(where demo is the name of the module that you wanted to test building)
|
Scott W. |
ok I'll try cleaning this all up. brb
|
Mar 6 | 4:15 PM |
Mark M. |
ooooo... found it!\
|
Mar 6 | 4:15 PM |
Mark M. |
in Studio, open the Gradle tool (docked by default on the right)
|
Mark M. |
on the root element of the tree, right-click, and choose "Refresh Gradle Dependencies"
|
Mark M. |
I think that will do it from within the IDE
|
Mar 6 | 4:20 PM |
Scott W. |
I've never done this. I'll be shocked if nothing breaks.
|
Mark M. |
if by "this" you mean refreshing dependencies, at least for the third-party ones, there is unlikely to be any actual effect, as you already have the right versions
|
Mar 6 | 4:25 PM |
Mark M. |
once you get your environment set up and working, you will need to keep in mind that, effectively, build.gradle is part of your source code, and if you change that, you need to publish a new version of the affected dependency
|
Mark M. |
and, in your case, that might also require publishing a new version of your hlsdk module as well
|
Mark M. |
if you are using semantic versioning, that might be a minor version or patchlevel change
|
Mark M. |
(sudokai: if you have a question, just let me know!)
|
Mar 6 | 4:30 PM |
sudokai |
Hey Mark
|
sudokai |
I'm investigating this crash
|
sudokai |
View paste
(1 more line)
|
sudokai |
It's not immediately evident what's going on
|
Mar 6 | 4:35 PM |
Mark M. |
what version of the androidx.fragment:fragment library are you using?
|
sudokai |
androidx.fragment:fragment-ktx:1.2.5
|
sudokai |
I think it happens when some fragment gets destroyed
|
Mark M. | |
Mark M. |
that has your crash, but it should have been fixed by 1.2.5
|
sudokai |
Thanks that's helpful
|
sudokai |
Do you think it might be a library bug?
|
Mark M. |
it is certainly possible, given that stack trace
|
Mar 6 | 4:40 PM |
Mark M. |
stack traces where the spot of the crash and the calling statements all come from a library frequently are due to library bugs
|
Mark M. |
assuming that your own code appears nowhere in the stack trace
|
sudokai |
I think I can reproduce the crash
|
Mark M. |
now, sometimes, the "library bug" is insufficient documentation or defensive programming, and the real cause is something that we did that used the library
|
Mark M. |
that certainly helps!
|
Mark M. |
(BTW, Scott: let me know if you have results from your testing!)
|
Scott W. |
:: everything is working well with the maven repo now! ::
|
Mark M. |
Scott: great!
|
Scott W. |
there were multiple issues left to work through, but cleaning the gradle cache was one of them. Good tip
|
Mark M. |
back when I used to regularly publish libraries, every time I did a release, one of my release steps was to do a --refresh-dependencies build, to better simulate what a consumer of my library would see and confirm that things built successfully
|
Mar 6 | 4:45 PM |
Mark M. |
(to be clear, a --refresh-dependencies build of my demo app module)
|
Mark M. |
usually it was fine, but every now and then it pointed out when I botched something
|
sudokai |
The crash happens when a fragment is still being created in a viewpager
|
sudokai |
And you hit back
|
Mark M. |
sudokai: that feels like the library should be able to handle that, so I'm back to "it's a library bug"
|
Mark M. |
tactically, you might be able to intercept back navigation and figure out something avoid the crash
|
Mark M. |
and, androidx.fragment:fragment is up to 1.3.0, so this might be fixed in the new version
|
sudokai |
So it's inside this androidx.fragment.app.BackStackRecord.setMaxLifecycle(BackStackRecord.java:245)
|
sudokai |
View paste
|
Scott W. |
:: I'm signing off. Thanks for help Mark! ::
|
sudokai |
Both fragment.mFragmentManager and mManager are null
|
Mark M. |
(Scott: you're welcome!)
|
sudokai |
And since we know that null != null
|
sudokai |
It crashes :)
|
Mar 6 | 4:50 PM |
Mark M. |
yeah, I'm definitely back to "it's a library bug"
|
Mark M. |
try 1.3.0 -- but, if you still see it there, and are in position to create a sample project that reproduces the problem, file a bug report!
|
sudokai |
Okay I'll check it out
|
sudokai |
Do you usually keep your dependencies up-to-date_
|
Mark M. |
if they crash, yes :-)
|
sudokai |
No, I mean, in general
|
Mark M. |
it depends a bit on the project
|
Mark M. |
for my book samples, I usually update them all as part of a release
|
Mark M. |
for my primary consulting customer, we upgrade sporadically and need to get better about it
|
Mark M. |
what I dislike is being forced to upgrade a dependency at an unplanned point, so I would prefer to "keep ahead of the curve"
|
sudokai |
I don't know if I should only upgrade when something breaks
|
sudokai |
Or keep updating
|
Mar 6 | 4:55 PM |
Mark M. |
IMHO, you do not need to be on the absolute latest version, but being years out of date is bad too
|
Mark M. |
in this case, 1.2.5 is not that old, so I would not have worried about it right now outside of it possibly fixing your crash
|
Mark M. |
if we were having this discussion next year at this time, I would be nudging you to upgrade that dependency
|
sudokai |
So, when do you upgrade your libraries
|
sudokai |
As a separate release
|
sudokai |
Or bundled with other changes
|
Mark M. |
for professional projects, ideally, I like to do it as a separate Jira ticket and pull request, just because there can be a lot of ancillary changes, such as fixes due to new Lint rules
|
Mark M. |
for example, for a recent bug fix, I had to upgrade us to the latest Material Components for Android, and that meant that I had a whole bunch of unrelated changes in a bug-fix PR, just because they changed Lint rules on us
|
Mark M. |
now, sometimes, to implement Feature X, we need a new version of a dependency, and so upgrading in that ticket+PR is unavoidable
|
Mark M. |
but, in terms of making sure we are not stale, I try to handle that as a separate ticket+PR
|
Mark M. |
in terms of releases, those dependency changes just roll into the regular release process
|
Mar 6 | 5:00 PM |
Mark M. |
(and therefore ideally are happening in a regular release, not some hot-fix)
|
sudokai |
That's a great idea
|
sudokai |
Thanks Mark!
|
Mark M. |
you're welcome
|
Mark M. |
and that's a wrap for today's chat
|
Mark M. |
the next one is Tuesday in the 8:30am US Eastern slot
|
Mark M. |
have a pleasant rest of your weekend!
|
Scott W. | has left the room |
sudokai | has left the room |
Mark M. | turned off guest access |