Comment by webdevver

5 days ago

very cool. termux has to be peak for unbridled nerddom, the new linux terminal in android 16 is really a pale shadow of it. you don't get access to anything non-virtual, not even the gpu (atleast, i couldn't get it to work.)

theres so much cool hardware on modern smartphones, with quite solid drivers by virtue of the (relatively stringent) android quality requirements, and its all locked away. video encoders, decoders, 3d accelerators, etc, but none of it is really accessible in a power-user kind of way.

some more thoughts...

the android development kit really is very heavy. compared to `gcc -o main main.cpp && ./main`, it is several orders of magnitude away.

the jetpack stuff and whatnot - the big android app shops probably do actually appreciate that stuff. but i wish the dev env 'scaled to zero' as they say, but in the sense of cognitive overload.

could it be time to move away from java, and shift towards everything being a native binary? we have the tools now to make it secure, and its not like phones get faster 'for free' anymore. it would also vastly simplify the developer experience.

You don't have to use Android. I've been using various GNU/Linux phones for the last 17 years, so being able to do `gcc -o main main.cpp && ./main` on a phone is just natural to me. Back in 2008, as a teenager, I could choose to spent my first earned money to get me either one of the first GNU/Linux phones on the market or the first Android phone, and I feel that as the time goes it only validates my decision.

  • What is your feedback in regards to battery? Android have been exhausted in development to optimize battery usage but I'm reading linux phones don't really care that much so you end up with a dead phone in less of a day.

    Has a power user, what has your experience been on that topic?

    I'd switch my phone to linux on a heartbeat because android apps seem compatible enough nowadays to run there too but battery is always the pressing limitation.

    My thanks in advance.

    • I'm using a Librem 5 and its battery life is good enough for me - it lasts pretty much exactly what's needed for me to get through a typical day, so I often get home with the battery almost but not entirely flat. When I know that I'm going to be using it more intensively or need it to last longer, I'll usually just put a spare battery into my backpack, but I rarely actually need to use it when these days you can just charge up in a train or tram.

      That's not a universal property of these devices though - N900 that I used previously could easily last a few days.

      3 replies →

  • I've been looking at Linux phones for a while, and now the latest 'sideloading' lockdown from Google has pushed me to seriously consider getting off Android. What phones do you use or recommend for someone who has a little Linux experience?

  • The only stopper for most of us fully moving to Linux phones are banking apps...

    I am interested to hear how you deal with that as a full linux phone user

It is possible to write native code for Android using Native Development Kit. Typical NDK use would be to develop a library that is then called into by java code. But one can make whole app with it, 100% java-free:

https://github.com/cnlohr/rawdrawandroid

  • It is never Java free outside games, because all relevant Android APIs are hidden behind JNI calls, implemented in Java.

    Also NDK is designed to produce shared libraries that are then loaded into the Java host process for the application, if not manually written, one gets the generic activity (NativeActivity or GameActivity) written by the Android team, expecting specific symbols on the shared library mapping to the native method declarations.

    https://developer.android.com/reference/android/app/NativeAc...

    https://developer.android.com/games/agdk/game-activity

    So while someone's own APK might be Java free, there will be Java on the process execution runtime.

  • Yes I am also interested in something like this 100% java-free but instead of C I'd prefer golang

    I have been thinking more and more about creating golang applications for android simply because of how much I admire f-droid.

    There are apps that have done this through 2 approaches

    https://github.com/xlab/android-go?tab=readme-ov-file (Either something like this) Or https://github.com/LeastAuthority/destiny which is a dart app but uses golang's backend using https://github.com/LeastAuthority/dart_wormhole_william TLDR: they create dart bindings to go code and run it on android...

    I know sooo many good golang applications on linux that I wish more people of android could access it and in an even nice way via something like f-droid so I am definitely contemplating what might be the best way for something like this...

    For rust applications, I think that tauri might make the most sense, but I am just curious as to what you guys think is the best way for a beginner to create a golang/rust android application without worrying *too much*

> the android development kit really is very heavy. compared to `gcc -o main main.cpp && ./main`, it is several orders of magnitude away.

> the jetpack stuff and whatnot - the big android app shops probably do actually appreciate that stuff. but i wish the dev env 'scaled to zero' as they say, but in the sense of cognitive overload.

I tried to build a small binary that listens for events and launches/wakes an app to do some automation. But apparently there's no way to send Intents or Broadcasts from native code? So I need to boot a JVM in the binary if I want it to communicate with anything else on the system!

Of course, you can always communicate via stdio, but that's useless because everything in Android speaks Intents/Broadcasts. Native code can also do raw Binder calls, but nothing on the system speaks raw Binder.

  • >But apparently there's no way to send Intents or Broadcasts from native code? So I need to boot a JVM in the binary if I want it to communicate with anything else on the system!

    There is "am" i think which can be invoked to do this.

    However, Termux API exists, and is a nice package for calling other services. They have the scripts interface, which calls the actual app over a socket. Kinda inefficient, but at least the work is done.

    • Yes, but the 'am' command is just a CLI Java program. At that point, it would be more efficient to just boot a JVM in the binary to avoid the JVM startup cost every time a Intent/Broadcast needs to be sent.

      I believe the Termux API relies on a Java/app process that runs in the background to do stuff in response to API calls. Though I guess you get it for free if you already have the API running for other reasons.

"could it be time to move away from java, and shift towards everything being a native binary?"

they literally do just that for fuchsia, but idk if google can pull this off tbh the tech DEBT is huge and massive undertaking that even google can be nervous

I mean this is their own fault too tbh, imagine windows that try to release every new release every year and try hard to add feature on top of that and it break down all API underneath

that's what happen to android and ios is