I’m trying to build normal Android apps on an Android phone. Yes, I know most people use an x86_64 system, or a Mac. But I want to build an app using my phone because I live off the grid and using a phone (and ARM processor) is much more energy efficient than a desktop or laptop. I would have to burn gasoline to generate power for a laptop, and I want to avoid doing that.
I have an Android project that requires Java 8, Platform 26 or higher, and Gradle. (https://github.com/vanilla-music/vanilla)
I’ve seen some projects like Termux with BuildAPKs build sample APKs, but they don’t need Gradle. So I set up a Debian Buster chroot, but the software is old (Gradle 4.4.1). With LinuxDeploy on a rooted phone I can run various different arm-based distros. So the problem really boils down to: How can I build apps on an arm64 machine?
2022 UPDATE
Inspired by this fantastic article I decided to try again:
https://www.hanshq.net/command-line-android.html
With a 4GB LinuxDeploy image of Debian 11 Bullseye, I was able to install build tools, platform tools, etc (see gitlab link below for exact setup). And with a tip from https://gitlab.com/fdroid/sdkmanager/-/issues/8 I was able to get past license agreements. But then when I run gradle build
, gradle downloads files for x86_64, and then of course the build fails.
So now I’m wondering: Why is gradle specifically requesting those build tools? How can I stop it from doing that?
2
Answers
You have to try using AIDE- IDE for Android Java C++ on https://play.google.com/store/apps/details?id=com.aide.ui
I’ve built fairly functional apps with this app: https://github.com/tyron12233/CodeAssist. It is a bit buggy but it supports Androidx and constraintlayout out of the box. Note that it is not as feature rich as Android Studio unfortunately.