Prerequisite: Ensure mkapk is installed. See the Installation Guide if you haven't done so yet.
Step 1: Initialize a New Project
Create a new directory and initialize mkapk project structure:
$ mkdir my-first-app
$ cd my-first-app
$ mkapk init
$ cd my-first-app
$ mkapk init
This creates the following structure:
my-first-app/
├── AndroidManifest.xml
├── andresguard-config.xml
├── assets
├── bin
│ ├── classes
│ │ ├── java_classes
│ │ └── kotlin_classes
│ └── debug.keystore
├── config.json
├── proguard-rules.pro
├── releases
├── res
│ ├── anim
│ ├── animator
│ ├── drawable
│ ├── drawable-night
│ ├── font
│ ├── layout
│ │ └── activity_main.xml
│ ├── layout-land
│ ├── menu
│ ├── mipmap
│ ├── values
│ ├── values-night
│ └── xml
└── src
├── C
│ └── core_logic.c
├── C++
│ └── native_bridge.cpp
└── com
└── example
└── polyglot
├── JavaBridge.java
└── MainActivity.kt
Step 2: Configure Your Project
Edit config.json to match your project. Here's a basic example:
{
"NAME": "MyApp",
"BIN_DIR": "./bin",
"SRC_DIR": "./src/main",
"RES_DIR": "./src/res",
"ASSETS_DIR": "./assets",
"MANIFEST": "./src/main/AndroidManifest.xml",
"SDK_ROOT": "~/android-sdk",
"TARGET_SDK": "34",
"JAVA_VERSION": "17",
"KEYSTORE": "~/.android/debug.keystore",
"KEYSTORE_ALIAS": "androiddebugkey",
"NDK_BIN": "~/android-ndk/toolchains/llvm/prebuilt/linux-aarch64/bin"
}
Important: Update the SDK_ROOT and NDK_BIN paths to match your Android SDK installation.
Step 3: Add Source Code
Create your first Java file. Open src/main/java/com/example/MainActivity.java:
package com.example;
import android.app.Activity;
import android.os.Bundle;
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
Step 4: Create AndroidManifest.xml
Create src/main/AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example">
<application
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher">
<activity android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Step 5: Build Your APK
Run a debug build:
$ mkapk build
For a release build with optimizations:
$ mkapk build -release
For multi-ABI universal APK:
$ mkapk build -ndk-all
Success! Your APK is ready. Find it in the
bin/ directory.
Step 6: Install and Test
Install the APK on your device using adb or direct installation:
$ adb install bin/MyApp.debug.apk
Common Build Flags
| Flag | Description | Example |
|---|---|---|
-release |
Production build with optimizations | mkapk build -release |
-all |
Force full rebuild (ignore cache) | mkapk build -all |
-ndk-all |
Build for all supported architectures | mkapk build -ndk-all |
-arch |
Build for specific architecture | mkapk build -arch aarch64 |
-no-obs |
Disable obfuscation in release build | mkapk build -release -no-obs |
Next Steps
- Read the Configuration Guide for advanced project setup
- Check the Usage Guide for all available commands
- Visit the FAQ for common questions