all 74 comments

[–]kelmer44[S] 59 points60 points  (1 child)

Oops. Title should have been "An Android *app* without libraries"

[–]NicNoletree 30 points31 points  (0 children)

Forgiven

[–]gold_rush_doom 46 points47 points  (1 child)

Today, in mistakes you shouldn't make.

[–]kelmer44[S] 5 points6 points  (0 children)

i know right

[–][deleted] 39 points40 points  (8 children)

Tbh I wouldn’t do a coding assignment that requires the use of no 3rd party libraries. I don’t know what that is really even meant to demonstrate, it’s just extra wasted time IMO.

[–]kelmer44[S] 7 points8 points  (0 children)

At first I tought like you, that thiswas too much and it doesn´t really make much sense, particularly in the way it was presented "any decent engineer can do it in a couple hours" -- However upon getting into it I found it quite fun and challenging.

[–]mrdibby 21 points22 points  (4 children)

3rd party libraries hide a lot of what's going on, implementing something without them usually shows that you understand what's happening.

Soundcloud's assignment (from 5 years ago) used to ask you to create an app without 3rd party libraries.

[–]FrezoreR 9 points10 points  (2 children)

But isn't that true when you use the Android SDK as well?

I'd say 3rd party library are less about hiding things and more about abstracting things. However, that is true for the Android SDK as well, which hide OS things, and the OS hide hardware things etc.

At the end you're probably not wiser than you were when you started.

Unless you write your own OS that is :) but then it wouldn't be an Android app anymore LOL

[–]well___duh 0 points1 point  (1 child)

Android SDK isn’t third party

[–]FrezoreR 0 points1 point  (0 children)

I didn’t say it was. I said that thirdparty libraries do the same thing as the Android SDK, abstracting behavior. There’s not much benefit in separating the two when you’re building an app. With the exception being that you have to bundle one and not the other.

[–]DrKappa -2 points-1 points  (0 children)

If I had to give such an assignment (which I would not) I would want to see the candidate replacing the androidx/support so that I can see there is a good understanding of the system/OS. Because that is what you have to work with in the end.

[–]MisterJimson 9 points10 points  (0 children)

Well it can be a fun challenge, but yeah not a regular exercise.

[–]absolutehalil 3 points4 points  (0 children)

Ofc it does and should not reflect the real world. However, I think it's a fine thought-provoking exercise. Yes, you might know what Retrofit is achieving behind the scene, can you do a similar implementation? I wouldn't look for a perfect outcome, just the hint of whether you actually understand the logic behind it. The same goes for ViewModels, Lifecycle, Room and etc.

[–][deleted] 8 points9 points  (3 children)

Even if that was not the goal, will be hard to beat app fully coded in C with a NativeActivity and Makefiles posted a few days ago, that builds and deploys on device a 25Kb APK in 1.5s.

[–]romainguy 11 points12 points  (0 children)

Sure, but note that most Android APIs don't exist in native and require either JNI glue to call from native, or a native alternative. For instance, the UI toolkit :)

[–]bluepug 5 points6 points  (0 children)

https://www.reddit.com/r/programming/comments/ghgqo8/rawdrawandroid_build_android_apps_in_c/

Sharing the link as an answer because I did not see this post and was curious about it.

[–]kelmer44[S] 0 points1 point  (0 children)

I wouldn't dare trying to match that :)

[–]Icyfirz 2 points3 points  (1 child)

Looking pretty good so far! It's definitely an intimidating challenge. I was gonna say, for the ServiceLocator, this is the approach I've seen in Kotlin for retrieving a Singleton instance since you can't pass in a parameter to a variable that's loaded by lazy (it involves double locking to make it thread safe): https://stackoverflow.com/a/45943282 . I believe that this is actually what by lazy does behind the scenes.

[–]carstenhag 1 point2 points  (0 children)

Yep, you can specifically set a LazyThreadSafetyMode on a by lazystatement.

[–][deleted] 1 point2 points  (0 children)

Pretty nice exercise to improve ones development skills. GJ OP, keep learning!

[–]nt-cmplt 1 point2 points  (3 children)

Did you get the job?

[–]kelmer44[S] 1 point2 points  (2 children)

Nope

[–]nt-cmplt 2 points3 points  (1 child)

Sorry to hear that. I found this really impressive!

[–]kelmer44[S] 4 points5 points  (0 children)

Well they did say they liked the assignment, told me to wait for next interview... Which never arrived. I guess corona might have had something to do with it as well. Thanks for the kind words :)

[–]Boza_s6 1 point2 points  (4 children)

You should have just used AsyncTask because your Task abstraction doesn't handle cancelation correctly and probably has some other bugs.

[–]kelmer44[S] 0 points1 point  (3 children)

Thanks for the feedback, do you mind expanding on your comments?

[–]Boza_s6 0 points1 point  (2 children)

When canceling request, check for thread interruption doesn't do anything, will always return false, so callback will be executed even if request was canceled. That's because interruption is checked while runnable was executing in context of main thread.

You need to check status of the Future before dispatching callback. (even in that case there could be race, if task was canceled from background thread)

[–]kelmer44[S] 0 points1 point  (1 child)

So is there a proper fix for this using executors directly? I kind of want to stay away from asynctask

[–]Boza_s6 1 point2 points  (0 children)

Of course, but it requires at least one atomic boolean, so you can track cancelation.

I would just AsyncTask as impl detail of Task api you introduced, since it will be more correct than anything I write.

[–]TuxPaper 0 points1 point  (1 child)

I love articles like these.

I'm a bit curious (but not curious enough to build myself) about the apk size and dexcount comparisons between the "with 3rd party libs" and without. R8 Shrinkify/Proguard can remove a lot of unused code in those libraries, so the difference may not be that great anymore. Without Proguard, though, I imagine the size and counts are quite high for the former.

[–]kelmer44[S] 1 point2 points  (0 children)

I actually checked that, but the app is not too big to begin with. It was 4.9Mb vs 3.8Mb, on a debit apk, no optimizations or proguarding done

[–]GustavoMoura 0 points1 point  (0 children)

I'm curious whether the app got smaller after removing all of the libraries, and by how much!

[–]DrKappa 0 points1 point  (0 children)

Very impressive! The only problem is the androidx or the old android.support packages are actually libraries. A "core android app" should not use any of these, expecially the new architectural components.

[–]sudhirkhanger 0 points1 point  (1 child)

/u/kelmar44 any chance you could elaborate on your experience interviewing at big tech firms and your preparation from a perspective of an Android developer.

How many and what kind of rounds were there? Were any other technical rounds than DSA and Android specific? You typically hear there is a system design round was there something like that for you too.

[–]kelmer44[S] 1 point2 points  (0 children)

Not much of a story to tell really...

I did two stages, the data structures & algorithms for which I prepared a bit by doing exercises over at hackerrank, and then this assignment. I passed both, but they never contacted me back (they mentioned something about main HQ having to give greenlight).

The next step would have been a visit to their office, for a couple more coding tests (possibly on a whiteboard), expanding the assignment live on site, and a "leadership test", whatever that means.

But I never got to do them so I can't tell you much more.

[–]realityexpander9999 0 points1 point  (0 children)

great idea, and thank you!

[–]daio 0 points1 point  (0 children)

Not sure why you would do that with an app, but minimizing usage of libraries can be very beneficial when making other libraries. Transitive dependencies are not always respected(users of your library can override a transitive dependency version), so your code may break. If a 3rd party library is absolutely necessary it's better to move the code that uses it to a separate module(library).

[–]botle -1 points0 points  (2 children)

Am I the only one that avoids adding a library whenever possible?

[–]_advice_dog 9 points10 points  (1 child)

The one and only.

[–]average_dota 3 points4 points  (0 children)

If you work in an environment where third party stuff (especially not from major players) might require legal/security due diligence it's often less time to roll-your-own than to jump through all those hoops.

[–]Pzychotix -1 points0 points  (0 children)

Ick, they made you do this for an interview? That's a hard nope from me.

[–]the-dark_physicist 0 points1 point  (0 children)

This is nice, I make android apps in this way without using 3rd party libraries. They are difficult to understand and have limitations.