Office Hours Transcript: 2021-05-10

Tad joined

Hey Mark!

I posted a new SO question, was wondering if you could point me in the right direction. It has to do with finding the best strategy to use to find if/where authors that had their content on jcenter have moved it somewhere else, and if so how to properly identify and use it in a gradle script. The post is here (kind of long, but I can summarize what I have tried and did not work): https://stackoverflow.com/questions/67472856/how-can-i-resolve-android-studio-4-2-build-errors-after-removing-jcenter

Essentially I tried to guess at a repository url based on what I saw in mvnrepository (which failed), then I found the .aar file and put it in my libs directory and referenced it both from a fileTree entry and a specific implementation entry, and both those failed as well.

generally, for open source libraries, your best approach is to go to the project Web site or version control repository (e.g., GitHub)

I did that for one of them - created my own project, built the aar file, deployed it to libs and referenced it.

That worked.

usually, instructions for where to get the artifacts are there, and there might be an issue tracker for seeing if anyone else has requested the migration, what the status is

That’s why I was confused that I couldn’t do that for the other ones I found.

well, your option 1 there is akin to putting in a maven line for Bing – mvnrepository.com is just a search engine

the library you use as an example there appears to be https://github.com/MiguelCatalan/MaterialSearchView

Well they also have a line that says something like "the artifact is located at the Spring repository" and gives a url

I had thought that might be a repository I could reference, but nyet.

I have trust issues with arbitrary artifacts from places other than where the developer distributes hem

the library in question has not been updated in four years, and the issue tracker seems fairly dormant

Yes I have visited the GitHub site, but couldn’t find any info on repositories (other than jcenter, which I’m trying to move off of

What I don’t understand is why deploying the actual .aar file and referencing in my build script also didn’t work.

so, in this case, either replace the library with something that is actively maintained, or actively maintain your own fork

the answer of "let me go grab a random AAR and use it" is not a really good solution, particularly since there is no fixed timetable for JCenter to stop serving artifacts

Yes there is - It is next Feb (2022)

Or maybe it is March next year, one or the other. I just read a blog from the CEO of JFrog

I think they even rescinded that one, though their flakiness means that we should still be moving

Oh, ok.

but, since you have 10 months, you should be seeking long-term sustainable solutions

in this case, it’s unlikely that the author is going to spring back into action, though it’s not out of the question

Well, a couple of these items are fairly stale at this point, that’s why I looked and found the .aar and just thought I would use those until I either replaced them or worked to no longer need them.

well, for that, you could just keep using JCenter for those

However a couple of big ones are Realm (which the Realm folks are working on now) and Google’s WebRTC

The latter one is a huge dependency for me.

I can’t seem to find other repositories I can reference from Gradle for it other than jcenter

and the real problem is I don’t know how to go about finding them.

what exactly is "Google’s WebRTC"? I see https://chromium.googlesource.com/external/webrtc/ but that seems to be tied to Chromium

implementation group: 'org.webrtc’, name: 'google-webrtc’, version: '1.0.32006'

Java SDK

It’s foundational WebRTC plumbing I use to make calls to webRTC service providers.

like XirSys

based on https://bintray.com/google/webrtc/google-webrtc it is being at least sorta maintained – last update was late August

Yeah - how do I go about finding other repositories I can reference from gradle it may be deployed to?

the opening paragraph there points to how you can build your own AAR

don’t know how they want you handling transitive dependencies, but I have not looked at their POM so they might not have anything too unusual

OK - good point. I won’t be needing an update in the near term, but that is good to know.

so, in this case, your provider is not going to move from JCenter, so you’re either going to have to get good at building AARs with their script or migrate to some other WebRTC stack

But the larger question - your suggestion is to go through the source local (like GitHub or what have you) and look for clues as to where else it might be maintained, of (like in this case) IF it is going to be maintained?

right

IMHO, right now, the primary concern is the "IF" part

because if the library looks unmaintained, you have time to migrate to something else

Yeah - the two biggies are that one and Realm. The others are more nice to haves (i.e. from Android Arsenal, etc.)

I have to assume that Realm is going to move, whether to Maven Central or their own repository

But the other thing I just don’t get is why I couldn’t get deploying the aar file to be recognized by gradle.

Even when I removed the old dependency line, and put in the new one referencing it from libs, or when I added 'aar' to my fileTree declaration - still wasn’t found.

implementation fileTree(include: ['.jar’,’.aar’], dir: 'libs')

what exactly were the symptoms behind "still wasn’t found"?

I get a build error that it can’t find materialsearchview 1.4.0 for example.

Just a sec I’ll generate it again

that implies that you still had the old implementation line lying around

I swear I commented it out, but I’ll double-check

your attempt 5 also should be OK, assuming that the filename matches what you have there: materialsearchview-1.4.0.aar

I am using that approach on my primary client’s project for pulling in a pair of AARs that are not distributed through an artifact repository (grumble, grumble)

"Could not resolve com.miguelcatalon:materialsearchview:1.4.0"

task generateDebugFeatureTransitiveDeps

that means you still have an implementation line referencing that artifact

or, something else’s POM has it

It’s in there but commented out

ok that might be

I haven’t checked all the various dependencies

in many ways, that’s the stickiest wicket with all of this: dealing with cases where some transitive dependency is the problem

you could probably hack something together by putting that AAR and some hand-generated POM in the mavenLocal() repository, but I’m not in position to walk you through those steps

do you have multiple modules? might it be some other module still refers to this?

Do I need to re-index each time I manually (i.e. outside of AS) drop an .aar file into libs?

I don’t think so, but I only infrequently do this

I have two modules - the other one is for downloading video onboarding content and its build.gradle doesn’t reference any of them

you could run a Gradle dependency report and see what’s trying to use this library

I’ve got all the .aar files for Realm, for WebRTC, etc. all in libs, and when I run the build I get:

Execution failed for task ':app:generateDebugFeatureTransitiveDeps’.

Could not resolve all artifacts for configuration ':app:debugRuntimeClasspath’.
Could not find io.realm:android-adapters:4.0.0.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/io/realm/android-adapters/4.0.0/android-adapters-4.0.0.pom
- https://repo.maven.apache.org/maven2/io/realm/android-adapters/4.0.0/android-adapters-4.0.0.pom
- https://jitpack.io/io/realm/android-adapters/4.0.0/android-adapters-4.0.0.pom
Required by:
project :app

Could not find org.webrtc:google-webrtc:1.0.32006.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/org/webrtc/google-webrtc/1.0.32006/google-webrtc-1.0.32006.pom
- https://repo.maven.apache.org/maven2/org/webrtc/google-webrtc/1.0.32006/google-webrtc-1.0.32006.pom
- https://jitpack.io/org/webrtc/google-webrtc/1.0.32006/google-webrtc-1.0.32006.pom
Required by:
project :app

Could not find com.l4digital.fastscroll:fastscroll:1.1.2.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/l4digital/fastscroll/fastscroll/1.1.2/fastscroll-1.1.2.pom
- https://repo.maven.apache.org/maven2/com/l4digital/fastscroll/fastscroll/1.1.2/fastscroll-1.1.2.pom
- https://jitpack.io/com/l4digital/fastscroll/fastscroll/1.1.2/fastscroll-1.1.2.pom
Required by:
project :app > com.github.broakenmedia:MultiContactPicker:1.8.5

Could not find com.miguelcatalan:materialsearchview:1.4.0.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/miguelcatalan/materialsearchview/1.4.0/materialsearchview-1.4.0.pom
- https://repo.maven.apache.org/maven2/com/miguelcatalan/materialsearchview/1.4.0/materialsearchview-1.4.0.pom
- https://jitpack.io/com/miguelcatalan/materialsearchview/1.4.0/materialsearchview-1.4.0.pom
Required by:
project :app > com.github.broakenmedia:MultiContactPicker:1.8.5

Possible solution:

com.github.broakenmedia:MultiContactPicker:1.8.5

that is what is requesting the MaterailSearchView

Yes I saw that - but that has absolutely nothing to do with realm for example

why would I be getting errors about that?

are you using MultiContactPicker in your app?

I am

it has transitive dependencies

libraries depend upon other libraries

I guarantee you that multi-contact picker doesn’t know anything about realm

so maybe I don’t understand "transitive" in this context…

no, MultiContactPicker is using MaterialSearchView

Ok that I get.

you are using MultiContactPicker

And I understand why that would throw an error about those two

but why the errors that it can’t find realm?

or webRTC?

presumably, you are using Realm

I have those .aar files in there also

in libs

It’s like it isn’t recognizing them there

your build.gradle appears to have an implementation line for io.realm:android-adapters:4.0.0

That’s what I’m trying to understand - how it searches

OK so even if I have the fileTree first, it won’t look there first?

if you request an artifact by the full coordinates (group:artifact:version), Gradle uses repositories

I assumed (wrongly?) that an implementation line means "I need this", and the fileTree line means "Look here for it"

not exactly

OK - so how does it work?

the repositories closure in your top-level build.gradle file says "look here for everything requested by full coordinates"

the fileTree one says "oh, yeah, grab these things too, even though we don’t really know what they are"

which is why fileTree is kinda the last resort

OK - roger that

So I need to remove any implementation line that references anything in fileTree, and also ensure I have that multicontact picker dependency dealt with

right

OK can do. Will give that a try. Thanks!

Btw - I didn’t quite understand the last comment you made from the prior session, did you mention you are getting your second vaccine shot?

tomorrow, yes

Ah, good for you!

I’m fully there myself.

hence the slight shift in the office hours schedule – I reacted a bit to the first shot, and by all reports it’s likely the second will be worse

Which one?

Pfizer

Yeah - I got that, and had a pretty sore arm on the second, plus one night of a fever.

Not super high - 100. Broke in a few hours.

Felt draggy for a day

yeah, fatigue was the issue for the first round, and I’m assuming more fatigue this time

Good luck!

thanks!

And thanks again, as always.

happy to help!

Btw - I was curious about your rep score on SO, holy cow. Almost a million. You have to be the leader in the clubhouse, no?

that depends on which clubhouse :-)

Android, yes; overall, I think I’m #7 or so

for what that’s worth

Well, it’s damn impressive. I used to moderate various tech forums back in the day, so I know the kind of time it takes.

thanks!

And what’s even more impressive is after all the (no doubt) silly questions (some of which from me!) which I know you must be doing an eye roll or two, you are still really polite and helpful.

Not easy. Particularly when you know a lot.

well, I’ll be honest, that varies – I definitely can be prickly at times

I have been trying to be better about it in recent years

Do you ever get to live events? (pre-pandemic of course)

Would be fun to shake your hand sometime…

do you mean conferences? if so, I used to speak a lot in the early years, but that’s tailed off

Yeah - that’s what I was thinking about.

Virtual has its place, but I do miss good technical conferences - particularly the breakout sessions.

Anyway - gonna jump. Thanks again.

have a pleasant evening!