- MCP server with stdio transport for local use - Search episodes, transcripts, hosts, and series - 4,511 episodes with metadata and transcripts - Data loader with in-memory JSON storage 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
77 lines
6.1 KiB
Plaintext
77 lines
6.1 KiB
Plaintext
Episode: 1562
|
|
Title: HPR1562: Android For The cli/c Junkie
|
|
Source: https://hub.hackerpublicradio.org/ccdn.php?filename=/eps/hpr1562/hpr1562.mp3
|
|
Transcribed: 2025-10-18 05:07:30
|
|
|
|
---
|
|
|
|
This episode of HBR is brought to you by AnanasThost.com.
|
|
Get 15% discount on all shared hosting with the offer code HBR15.
|
|
That's HBR15.
|
|
Better web hosting that's Aniston Fair at AnanasThost.com.
|
|
Hello and welcome to our show, this will be a fun one.
|
|
My name is Sikflops and you're listening to another edition of Hacker Public Radio.
|
|
In this episode we're going to be bringing together my three favorite things,
|
|
Android, the command line and C. We're bringing these three things together so that we can program
|
|
Android apps on the command line that are written in C. Then we'll compile an example app I've
|
|
written for you called Pants that plays an MP3. Writing apps in C on Android is possible using
|
|
the freely available Android NDK or native development kit. The example I've written,
|
|
I've packaged with SDL2, SDL2 image, lib mad, lib jpeg and lib png.
|
|
So that's right awesome. You can use it in your demo framework, which is what I'm doing.
|
|
The example simply runs in landscape mode and plays an MP3 all using C.
|
|
So here we go.
|
|
First things first, this is off for Linux. The Android NDK uses pre-compiled GCZ cross-compala suite
|
|
that's compiled for Linux. So let's get out our Linux box. You'll need Java installed.
|
|
How to install it is unique for every distribution. On CentOS I did yum installed Java
|
|
Astrich to install Java. Google help you install Java for your platform. Most platforms I imagine
|
|
is a yum or an app to get away. I can only tell you about CentOS because that's the only
|
|
thing I've installed the NDK on. Once you've got Java installed, Mozeon over to developer.android.com
|
|
and download the Android SDK. There's a readme in there that tells you to run tools,
|
|
slash Android update SDK, dash dash no UI. I suggest you do that. It'll take a while to complete
|
|
because it's installing lots of stuff for multiple Android APIs.
|
|
Now this is not the typical way to install what just happened, but I found it's one way to do it
|
|
on CentOS. First thing I did was I moved Android SDK to user local share, slash Android SDK Linux.
|
|
In that directory, I also created a bin directory and put wrappers for every utility found in the
|
|
tools directory in there. The wrappers simply run an absolute path of the corresponding utility
|
|
with all arguments copied. And after that, I edited Etsy slash profile.d and added android.sh
|
|
exporting the path of the newly created bin directory. Making that bin directory was kind of
|
|
not a way to install the Android SDK, but I found it was the simplest way to do it after a lot of
|
|
frustration. Type Android on the command line to test it. You'll get some errors, but as long
|
|
as their Java shares, that means you're on the right track. Next, we need the Android NDK.
|
|
You can download that from developer.android.com. Again, its installation is pretty straightforward.
|
|
Just pop it in user local share and modify Etsy profile.d slash Android.sh to export an additional
|
|
path to that directory. All we want from this is the utility NDK build in our path.
|
|
After this, we need a pochi ant. You can find ant at ant.apochie.org. Pop that again in user
|
|
local share and edit Etsy profile.d slash android.sh to export ant home. All caps with an underscore
|
|
to that directory. You also want to export Java home to the containing directory of your Java
|
|
command. And that's it. That's how you install everything. It's pretty straightforward.
|
|
Now, continuing on, we ought to install my app. This example is based on MGR Hardee's work.
|
|
It's extended to the new SSTL containing my favorite libraries. I made it so you can easily
|
|
modify it to suit your own app. Download this at theatasilva.com slash pants.tar.gz.
|
|
All the links will be in the show notes. Once you've downloaded that, untard into your
|
|
favorite directory and type make. I'll take a while, but it should eventually produce app.apk
|
|
in the same directory, if all is well with the world. App.apk is your application package.
|
|
Signed by the Android debug key. If you want to sign it with your own dev key, type make release.
|
|
And that'll produce app release unsigned.apk. Using Jars signer, you can sign it,
|
|
then you'll need to run zip align on the app before publishing it. All this information about
|
|
signing apps can be found from the Android project. First thing you'll notice about the app is
|
|
that it's called pants. You want to open up the readme file, and that will have instructions on
|
|
how to change the name, change the icon, the permissions, and whatnot. The Android project
|
|
source tree for pants looks pretty simple. We have a few directories, the asset directory that
|
|
contains our app resources. SDLs are WOPS reads into this directory. Then we have JNI. This is where
|
|
all our C source code goes. I believe JNI stands for Java Native Interface. Then after that,
|
|
we have res. This contains things like strings, our layout XML, and our icon. And then finally,
|
|
we have SRC. This contains our Java source code. Where you want to put your source code is in Android
|
|
project slash JNI. That's the JNI the JNI directory that we just talked about slash SRC.
|
|
Keep in mind that you want your entry function to still be called STL underscore mean.
|
|
And that's that's pretty much how you do it. Help with this information. You can go ahead and
|
|
start writing your own C Android applications. Take care everyone, and thank you for listening. Bye-bye.
|
|
You've been listening to Hacker Public Radio at Hacker Public Radio. We are a community podcast
|
|
network that releases shows every weekday Monday through Friday. Today's show, like all our shows,
|
|
was contributed by an HPR listener like yourself. If you ever thought of recording a podcast,
|
|
then click on our contributing to find out how easy it really is. Hacker Public Radio was
|
|
founded by the digital dog pound and the infonomicon computer club, and it's part of the binary
|
|
revolution at binref.com. If you have comments on today's show, please email the host directly,
|
|
leave a comment on the website, or record a follow-up episode yourself. Unless otherwise status,
|
|
today's show is released under Creative Commons, App Tribution, share a light 3.0 license.
|