4 ms·
Context: I developed Android professionally apps at Google & FB from 2010-2021/ and as a hobby dev during that time. I personally blame gradle for the complexi
by sxp 2y ago
Context: I developed Android professionally apps at Google & FB from 2010-2021/ and as a hobby dev during that time.
I personally blame gradle for the complexity. It's such a horrible system for builds, and when I was developing Android apps on my own, I would avoid it at all costs. Using buck/bazel/blaze resulted in a much cleaner build process. It's been a while since I've wrote Android apps, but I've included a minimalist BUCK build file with Java + C++ components below. Note how it just has two build rules for the Java and cpp code. And it only requires 5 for a minimal Java/cpp app. If it was a pure Java app, it would just require the one build rule alone with a .java file and an AndroidManifest.xml.
At the same time, I needed to maintain a public facing SDK so I needed to learn gradle which was an absolute nightmare. I spent way too much time reading docs on the build system compared to doing something useful with it.
I'm not sure what the current state of the ecosystem is with Kotlin and modern Android Studio, but if I had to develop Android apps on my own again, I would start with bazel or buck for anything that's more than a Hello World template. I would recommend the same for anyone just starting out with Android development who is familiar with CLI-based development. One useful learning experience was to unzip an APK and figure out the individual build steps that converted a set of source files into the final APK. With bazel/buck, you can give it an option that causes it to print every build step which involves the build system calling Android SDK build tools on source files. Then you can manually run this commands yourself to see what they do. Doing this will tremendously help you debug any build issues and teach you how to remove bloated items from your build process.
https://medium.com/androiddevnotes/the-internals-of-android-apk-build-process-article-5b68c385fb20 https://medium.com/androiddevnotes/the-internals-of-android-... is a good starting point. In particular, read the section about "Understanding each part of the process" until you understand exactly what each box in that diagram represents.
android_binary(
name = "one",
srcs = ["TestOneActivity.java"],
custom_package = "me.sxp.test.one",
manifest = "AndroidManifest.xml",
deps = [":libone"],
)
cc_library(
name = "libone",
srcs = [
"jni.cpp",
"testonelib.cpp",
"testonelib.h",
],
)