config.json Reference
The config.json file is the heart of your mkapk project. It defines all build settings and project structure.
Basic Structure
{
"NAME": "MyApplication",
"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",
"COMPOSE_PLUGIN": "",
"PROGUARD_RULES": "./proguard-rules.pro",
"KEYSTORE": "~/.android/debug.keystore",
"KEYSTORE_ALIAS": "androiddebugkey",
"NDK_BIN": "~/android-ndk/toolchains/llvm/prebuilt/linux-aarch64/bin",
"SYSTEM_SHARED_LIBS": ["c++_shared"],
"NATIVE_TARGETS": []
}
Field Reference
| Field | Type | Required | Description |
|---|---|---|---|
NAME |
String | Yes | Application name (used for APK filename) |
BIN_DIR |
String (path) | Yes | Build output directory |
SRC_DIR |
String (path) | Yes | Source code directory (Java/Kotlin) |
RES_DIR |
String (path) | Yes | Android resources directory |
ASSETS_DIR |
String (path) | No | App assets directory (images, data files) |
MANIFEST |
String (path) | Yes | Path to AndroidManifest.xml |
SDK_ROOT |
String (path) | Yes | Android SDK root directory |
TARGET_SDK |
String (number) | Yes | Target API level (e.g., "34" for Android 14) |
JAVA_VERSION |
String (number) | No | Java source compatibility (default: "17") |
COMPOSE_PLUGIN |
String | No | Jetpack Compose plugin name |
PROGUARD_RULES |
String (path) | No | ProGuard/R8 obfuscation rules file |
KEYSTORE |
String (path) | Yes (for release) | Release keystore file path |
KEYSTORE_ALIAS |
String | Yes (for release) | Keystore certificate alias |
NDK_BIN |
String (path) | No | Android NDK bin directory (for native compilation) |
SYSTEM_SHARED_LIBS |
Array[String] | No | System libraries to include (e.g., c++_shared, log) |
NATIVE_TARGETS |
Array[Object] | No | Native compilation targets (see below) |
Native Targets Configuration
Define native C/C++ compilation targets:
"NATIVE_TARGETS": [
{
"NAME": "mynativelib",
"SOURCES": [
"src/native/main.cpp",
"src/native/utils.cpp"
],
"EXTRA_FLAGS": [
"-fexceptions",
"-frtti",
"-std=c++17"
]
}
]
Native Target Fields
| Field | Type | Description |
|---|---|---|
NAME |
String | Library name (output: libnamehere.so) |
SOURCES |
Array[String] | List of .cpp, .c, .h files to compile |
EXTRA_FLAGS |
Array[String] | Additional compiler flags (e.g., -std=c++17) |
System Shared Libraries
Specify shared libraries to include in your APK:
"SYSTEM_SHARED_LIBS": [
"c++_shared",
"log",
"android",
"EGL",
"GLESv2"
]
ProGuard Configuration
Create a proguard-rules.pro file for code obfuscation (release builds only):
# Keep all public classes and methods
-keep public class * {
public *;
}
# Keep native methods
-keepclasseswithmembernames class * {
native ;
}
# Keep enumerations
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
# Keep activity names (required for app to run)
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
Example Configurations
Simple Java App
{
"NAME": "SimpleApp",
"BIN_DIR": "./bin",
"SRC_DIR": "./src/main",
"RES_DIR": "./src/res",
"MANIFEST": "./src/main/AndroidManifest.xml",
"SDK_ROOT": "~/android-sdk",
"TARGET_SDK": "34",
"JAVA_VERSION": "17"
}
App with Native Code
{
"NAME": "NativeApp",
"BIN_DIR": "./bin",
"SRC_DIR": "./src/main",
"RES_DIR": "./src/res",
"MANIFEST": "./src/main/AndroidManifest.xml",
"SDK_ROOT": "~/android-sdk",
"TARGET_SDK": "34",
"JAVA_VERSION": "17",
"NDK_BIN": "~/android-ndk/toolchains/llvm/prebuilt/linux-aarch64/bin",
"SYSTEM_SHARED_LIBS": ["c++_shared", "log"],
"NATIVE_TARGETS": [
{
"NAME": "mylib",
"SOURCES": ["src/native/main.cpp"],
"EXTRA_FLAGS": ["-std=c++17"]
}
]
}
Release Build Setup
{
"NAME": "ProductionApp",
"BIN_DIR": "./bin",
"SRC_DIR": "./src/main",
"RES_DIR": "./src/res",
"MANIFEST": "./src/main/AndroidManifest.xml",
"SDK_ROOT": "~/android-sdk",
"TARGET_SDK": "34",
"JAVA_VERSION": "17",
"PROGUARD_RULES": "./proguard-rules.pro",
"KEYSTORE": "~/my-release.keystore",
"KEYSTORE_ALIAS": "my-key-alias"
}