跳转到内容

简体中文

简体中文

主题

Android Application

我们可以使用 android.native_app 规则来构建 Android 原生应用程序。

Native App

EXPLORER
src
android
AndroidManifest.xml
main.cpp
xmake.lua
Lua xmake.lua
12345678910
add_rules("mode.debug", "mode.release")

target("android_app")
 set_kind("binary")
 add_files("src/*.cpp")
 add_rules("android.native_app", {
 android_manifest = "src/android/AndroidManifest.xml",
 package_name = "com.xmake.demo",
 android_sdk_version = "35"
 })

Build and Run

bash
$ xmake f -p android --ndk=/path/to/ndk
$ xmake
$ xmake install
$ xmake run

自定义 Glue

如果你想使用自定义 glue 代码(或标准的 android_native_app_glue),你可以通过创建包含相应 AndroidManifest.xml 和原生代码的项目来实现。

EXPLORER
src
android
AndroidManifest.xml
main.c
xmake.lua
Lua xmake.lua
12345678910
add_rules("mode.debug", "mode.release")

target("app")
 set_kind("binary")
 add_files("src/*.c")
 add_rules("android.native_app", {
 android_manifest = "src/android/AndroidManifest.xml",
 package_name = "com.xmake.custom_glue",
 android_sdk_version = "35"
 })

AltStyle によって変換されたページ (->オリジナル) /