Office Hours — Today, February 11

Tuesday, February 9

Feb 11
7:25 PM
Mark M.
has entered the room
7:25 PM
Mark M.
turned on guest access
Scott W.
has entered the room
Scott W.
Howdy
Mark M.
hello, Scott!
how can I help you today?
tekconsult@dataeffects.com
has entered the room
tekconsult@dataeffects.com
has left the room
Scott W.
I am about to have to start distributing an Android library, and I'm completely in the dark about that process.
Mark M.
distributing to whom? a team? the general public?
7:30 PM
Scott W.
one of my company's customers at first, but other customers will want it eventually.
tekconsult@dataeffects.com
has entered the room
Mark M.
but, not to arbitrary developers? IOW, you want to limit access just to those customers?
(BTW, hello tekconsult! I will be with you shortly!)
Scott W.
I'm not sure how important it is for it to be private. I think that's the direction we want to go, but even if someone else got a hold of it they wouldn't be able to use it without an auth token.
Mark M.
it will be substantially simpler if you were to make the library publicly available -- then, you could arrange to host it on Maven Central, for example
and there is quite a bit written about that, particularly within the last couple of weeks
Scott W.
what happened recently?
Mark M.
if you look at your project's top-level build.gradle file, you will probably see references to an artifact repository called JCenter (represented by the jcenter() call in a repositories closure in Gradle)
JCenter is being shut down
Scott W.
oh boy
Mark M.
it will not accept updates or new artifacts shortly and will then be read-only for several months before going "poof"
so, developers who published libraries to JCenter are working on finding new homes
for many, that will be Maven Central
7:35 PM
Mark M.
if you decide that you do not want to make it publicly available, a Maven-style artifact repository is still the simplest approach from your customer's standpoint, in terms of integrating into their own projects
in the end, a Maven-style artifact repository is really just a directory tree with some metadata and your library
so, for example, I published my CWAC libraries using Amazon S3
however, dealing with security for a private repository is going to be somewhat more annoying, enough that your firm might consider a commercial repository system
Sonatype's Nexus or Artifactory are two that I know of
I have not used either
Scott W.
so if we just host all our libraries on an S3 bucket, our customer could have a one-line implementation dependency in their build.gradle?
Mark M.
it would only be one line if the S3 bucket were publicly visible and you were relying on "security by obscurity"
Scott W.
ok can you point me to information on that process?
Mark M.
I can do some poking around and will try to get you something before the end of the chat -- I don't have any links handy
Scott W.
I'm looking at this now
ok. I'll do some reading for a few minutes
7:40 PM
Mark M.
based on a quick skim, other than it being from 2017, it's probably not bad
let me take a question from tekconsult, and I'll come back to you in a bit
tekconsult: hi! how can I help you today?
tekconsult@dataeffects.com
View paste
I have a recycler that typically has 10-20 items that change frequently through a push notification.

Each item needs a countdown timer counting down by 1 second.

Putting the countdown in the recycler doesn't work because the textview is changing and I can't find a way
to cancel the handler on the textview to stop the countdown. Plus potential problem of memory leakage if handler stays active on every textview.

So is this the best way of handling:
put the timer inside the fragment (a runnable) then
recreate the list for the recycler every second so the time in the textviews can be updated?
Mark M.
I agree with the notion of a single timer, rather than one per row
you could try saying that on each timer tick that you update your model data and call submitList() on your ListAdapter to update the countdown text, but I do not know how well that would work
at a lower level, you could ask the RecyclerView for the visible rows, iterate over them, and just update each countdown text
that would be faster than the submitList() option, but you would have to test your logic to make sure that scrolling is OK
and, frankly, for 10-20 items, I would lean towards dumping the RecyclerView entirely
just put the 10-20 items in a LinearLayout or ConstraintLayout and wrap it in a NestedScrollView
that will be *much* simpler to update deterministically
7:45 PM
tekconsult@dataeffects.com
View paste
But still only have one timer and iterate over the views that I would build dynamically in the Layout (on the push notification)? 
And how would I find visible rows if I keep the recycler?
Mark M.
"But still only have one timer and iterate over the views that I would build dynamically in the Layout (on the push notification)? " -- yes
"And how would I find visible rows if I keep the recycler?" -- there are methods for it on RecyclerView
tekconsult@dataeffects.com
Thank you for the ideas to try.
tekconsult@dataeffects.com
has left the room
Mark M.
Scott: back to you!
https://proandroiddev.com/creating-a-private-ma... covers the same basic topics, but using GitLab rather than Amazon S3 as the host
https://dev.to/narayanansampath/publish-android... is really new but is pretty thin and looks like it just repeats what was in the post you were looking at
7:50 PM
Scott W.
ok I've some questions about how this all works still
in the first example, he adds his S3 bucket as a maven repo
is that a correct description of what's happening?
Mark M.
if you mean in the "Using Your New Dependency" section, yes
Scott W.
ok
and what exactly makes it a Maven repository? Is it the pom.xml?
Mark M.
that supplies metadata about your library
which is a key part of the repository entry for that library
there is also a specific directory structure that a repository will follow, based on your artifact group ID and artifact name
for my own repo, I have my own scripts to sync with S3, because my work there pre-dated any of these newer recipes
but plugins like maven-publish will set up that directory structure for you (AFAIK)
Scott W.
this is one of our dependencies.
com.opentok.android:opentok-android-sdk that's the actual line in build.gradle.
Mark M.
right
the POM will contain information about that dependency
7:55 PM
Mark M.
so when your customers have an implementation line for your library in their dependencies {}, they will pull in tokbox automatically
Scott W.
can I view the tokbox pom?
Mark M.
that link is for 2.18.1 for that library
and shows the four files for that version that Bintray is serving: the AAR, the POM, and MD5 hashes for each
if you click the link for the POM, it should prompt you to download it
Scott W.
ok I see that
Mark M.
usually, POMs are generated by a Gradle plugin
though there is nothing stopping you from hand-maintaining that XML, if you really like angle brackets :-)
Scott W.
plugin good
so, the pom is a lot smaller than I though tit would be.
it just shows 1 dependency of androidx.annotation
8:00 PM
Mark M.
right, they are fairly self-contained, apparently
Scott W.
ok so for my sdk
we have 7 modules
but the app should only depend on 1 of those modules
Mark M.
that 1 module pulls in the other 6?
Scott W.
yeah
Mark M.
OK, all 7 will go into your repository, but from a documentation standpoint, you would be telling your customers only about the 1
Scott W.
so they would have a dependency like com.me.theone:1.0.0
and that would have a pom file that declares the other 6?
Mark M.
yes
plus any other dependencies it might have (e.g., on Jetpack libraries), if any
Scott W.
oh yeah there are tons of libraries to include
actually
I've got all these androidx libraries declared in all 7 modules.
eh. I don't want to open that can right now actually.
ok so I've got this pom file generated by a pluggin
it's hosted on our S3 bucket along with aars for all of my modules?
8:05 PM
Mark M.
if you have 7 modules to publish, you will have 7 AARs and 7 POMs
Scott W.
ok
how long would you expect a competent person to set this up?
Mark M.
I haven't used modern recipes from scratch
so I'm not really a good judge of that
Scott W.
ok
Mark M.
what I would consider doing is setting up a scrap library and scrap project and experimenting with the basics
Scott W.
what would change if we did this the public maven way?
Mark M.
other than Amazon S3, you would choose your public Maven repository (Maven Central) and follow their instructions
from your customers' standpoint, one advantage of Maven Central is that they do not need to do anything special to use your library, beyond add the one implementation line
as they either presently have or will soon have the mavenCentral() line already set up in their top-level build.gradle
rather than having to paste in that S3 block and deal with passwords, etc.
Scott W.
right
8:10 PM
Mark M.
in the end, you will still have 7 AARs and 7 POMs
Scott W.
what is Bintray?
Mark M.
it's merely a matter of where they reside and how customers get to them
effectively, it's a superset of JCenter, as I understand it
Scott W.
shoot I think you're right
it's going away too
Mark M.
and, as you can see by that "Deprecation Notice" banner at the top of those tokbox pages, it too is going away
right
Scott W.
ok where is maven central?
Mark M.
that's a third-party site
the official search site is https://search.maven.org/
it's managed by Sonatype, just as JCenter/Bintray are managed by JFrog
JFrog is just electing to dump the public service and focus on their commercial offerings
Scott W.
ok I'd like to switch gears for the last part of this
a little switch
8:15 PM
Scott W.
let's say tomorrow rolls around and I'm struggling with this maven stuff but my boss is all "you better get me a solution by 5pm!"
hypothetically
Mark M.
I *love* hypothetical bosses! :-)
Scott W.
I could just send this company the 7 AARs and the list of dependencies that those AARs need and tell them to include it all in their dependencies right?
Mark M.
they could drop the AARs into some directory (e.g., libs/) and include them that way
they would not get the transitive dependencies, though, so you would have to document that as well
and then shipping them updates is a pain, and keeping the versions in sync is a pain, and...
now, big companies go this route -- the Apple Music SDK is distributed that way, for example
so it's not completely insane, but unless you need this by tomorrow 5pm, I'd aim for using an artifact repository
Scott W.
yeah
Mark M.
but, it might be you manually distribute the AARs as a stopgap and migrate that one customer to the repository solution when it is ready
Scott W.
right, I think boss will like that idea. Unless I can figure out the maven stuff real quick.
what are the costs to using maven central?
Mark M.
free AFAIK
it's basically marketing for their commercial products/services
Scott W.
how do I tell which of my dependencies are transitive?
8:20 PM
Mark M.
if we think of your 1 root library... everything in dependencies {} in that module's build.gradle is a transitive dependency for whoever tries using that library
Scott W.
ko
Mark M.
the plugin that generates your POM will set up the dependency entries for you
Scott W.
will I still be able to use my sdk as submodules like normal for my own app?
Mark M.
yes, though I warn you that at some point you're going to want to start "dogfooding" that SDK, to make sure it works as you expect as you publish updates
Scott W.
hmm
Mark M.
that could be in the form of a demo app that your customers use to learn how to use your SDK
Scott W.
yeah I've got a demo app
and our own app on top of it all
our own app uses the sdk differently than the demo app and our customers though
and no one really tests the demo app.
Mark M.
guess what! you're probably going to need to start testing the demo app :-)
Scott W.
yup
Mark M.
basically, if this is going to customers, your SDK is part of your product now, and you will need to treat it as such
documentation, testing, demo apps, support, etc.
Scott W.
yeah I agree.
8:25 PM
Mark M.
hopefully, so does your hypothetical boss
Scott W.
it's all about where do we spend our resources right now
last question:
I've been trying to convince my company to hire someone that really knows their stuff with Android development.
they keep bringing on "senior developers" from contracting companies that aren't cutting it.
I've ended up teaching these guys.
Do you have any advice on how to quickly figure out the... level of Android development someone is at?
Mark M.
not really, insofar as I don't interview developers much, and I am assuming that you are asking for something along those lines
Scott W.
yeah
Mark M.
live coding in an interview seems to be gaining steam -- that has pros and cons but it definitely gets to the crux of your concern
Scott W.
ok I'll try this on the next guy.
All right. Thank you so much for your time!
Mark M.
happy to help!
Scott W.
we packed a lot in.
Have a good night!
Mark M.
the transcript will be up on https://commonsware.com/office-hours/ shortly
and, have a pleasant evening!
8:30 PM
Scott W.
has left the room
Mark M.
turned off guest access

Tuesday, February 9

 

Office Hours

People in this transcript

  • Mark Murphy
  • Scott Wehby
  • tekconsult@dataeffects.com