Hacker News new | ask | show | jobs
by vbezhenar 908 days ago
Is it even supported way to write Android apps without compat libs? I tried to do that, and struggled. I hate dependencies and prefer to avoid them, however with Android that seems almost unavoidable (or requires expert knowledge of quirks of different Android versions, I guess).
4 comments

Mastodon app is built like that, the release apk is around 3 Mb, ~half of which is resources: https://github.com/mastodon/mastodon-android

Though it's not without compromises — because of Google's stupid policy that "nothing goes into the system unless it needs direct access to privileged or private system components", RecyclerView, ViewPager, and some other basic UI components are still AndroidX libraries that depend on AppCompat for no good reason. I had to fork them to rid them of that dependency: https://github.com/grishka/LiteX

Is this a supported thing to do? No. Do I care about it being unsupported? Also no.

It's not difficult to write sub-10Mb release APK for a production app with lots of features while using all the compat libraries and other useful dependencies (that do make life a lot easier). Our app is ~7Mb, and we don't even heavily optimize for APK size.

IME biggest dependencies are not compat libraries or _typical_ dependencies that Android apps need (like image loaders), but anything that involves native code. Media capabilities is one thing, but also solutions for analytics/user monitoring/SDKs for integration with Important Companies are more often than not _massive_, and companies like to track the user from many angles ¯\_(ツ)_/¯

AppCompat/JetPack don't do anything magical - they are just regular open source libraries.

If your app wants to use features which behave differently depending on the OS version, you have to if/else over the OS version. Also, note that the platform's Fragment implementation is deprecated and you might miss ViewModel.

Yes, after all, the Compat libs themselves need to talk to OS. But there's a reason why you were struggling - those libs have code that handles changes of API between different OS versions and there's been many of those during 14 major Android releases. Patching up those differences is after all the primary purpose of compat libs.
If you target latest OS - yes.