1
0
Fork
You've already forked myna
0
Template with a minimal native Android application in C.
  • C 99%
  • Makefile 1%
2025年12月14日 13:30:13 +01:00
app/src/main Refactoring code and several improvements. 2025年11月29日 20:44:59 +01:00
.clang-format Refactoring code and add clangd LSP config files. 2025年11月16日 16:50:20 +01:00
.clangd Refactoring code and add clangd LSP config files. 2025年11月16日 16:50:20 +01:00
.env.example First commit: minimal (template) native application Android. 2025年11月02日 20:28:16 +01:00
.gitignore First commit: minimal (template) native application Android. 2025年11月02日 20:28:16 +01:00
Makefile First commit: minimal (template) native application Android. 2025年11月02日 20:28:16 +01:00
README.md More resources and examples. 2025年12月14日 13:30:13 +01:00

My Native Application (myna)

A Hobby project to learn about developing Native Applications in C for Android.

Here you can see a minimal template for develop Native Applications in C for Android.

Tools needed:

  • Android SDK
  • Android NDK

Keystore File

Ensure the keystore file mykeystore.jks exists in the directory where Makefileis, or create one with:

keytool -genkeypair -dname "cn=Mark Jones, ou=JavaSoft, o=Sun, c=US" -alias business -keypass your_password -keystore mykeystore.jks -storepass your_password -validity 20000 -keyalg RSA

Environment File

Copy and paste .env.example file to .env one, and complete the environment variables.

BUILD_TOOLS_VERSION and ANDROID_TARGET can be changed. If you need install new build tools versions use this command:

sdkmanager "platforms;android-30" "build-tools;30.0.3"

In the above command an Android 30 platform and build tools 30.0.3 versions are downloaded. And then you could use them for ANDROID_TARGET and BUILD_TOOLS_VERSION.

Build Process Overview

  1. Native Code Compilation: The NDK builds the C code into shared libraries for armeabi-v7a and arm64-v8a architectures
  2. APK Creation: An empty APK is created with the manifest, resources, and assets
  3. Library Inclusion: Native libraries are added to the APK in the correct location (lib/<abi>/)
  4. Alignment: The APK is aligned for better performance
  5. Signing: The APK is signed with the provided keystore
  6. Cleanup: Temporary files are removed

The project is ready to build/install/debug using Makefile. Read it to see targets. Basically, you can:

  • Install in the device connected to your computer (make install)
  • Debug the app from device connected to your computer (make debug)

Resources

Notes

  • android_native_app_glue.h/.c files simplify lifecyle management and they can be found on NDK folder sources/android/native_app_glue
  • All NDK headers can be found on NDK folder toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include
  • All NDK libraries can be found on NDK folder toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib