11const std = @import ("std" );
22const builtin = @import ("builtin" );
3- const android = @import ("zig- android-sdk " );
3+ const android = @import ("android" );
44
55pub fn build (b : * std.Build ) void {
66 const root_target = b .standardTargetOptions (.{});
@@ -21,7 +21,16 @@ pub fn build(b: *std.Build) void {
2121 const android_tools = android .Tools .create (b , .{
2222 .api_level = .android15 ,
2323 .build_tools_version = "35.0.0" ,
24- .ndk_version = "27.0.12077973" ,
24+ .ndk_version = "29.0.13113456" ,
25+ // NOTE(jae): 2025-03-09
26+ // Previously this example used 'ndk' "27.0.12077973".
27+ //
28+ // However that has issues with the latest SDL2 version when including 'hardware_buffer.h'
29+ // for 32-bit builds.
30+ //
31+ // - AHARDWAREBUFFER_USAGE_FRONT_BUFFER = 1UL << 32
32+ // - ndk/27.0.12077973/toolchains/llvm/prebuilt/{OS}-x86_64/sysroot/usr/include/android/hardware_buffer.h:322:42:
33+ // - error: expression is not an integral constant expression
2534 });
2635 const apk = android .APK .create (b , android_tools );
2736
@@ -47,7 +56,7 @@ pub fn build(b: *std.Build) void {
4756
4857 for (targets ) | target | {
4958 const exe_name : []const u8 = "sdl-zig-demo" ;
50- var exe : * std.Build.Step.Compile = if (target .result .isAndroid () ) b .addSharedLibrary (.{
59+ var exe : * std.Build.Step.Compile = if (target .result .abi == .android ) b .addSharedLibrary (.{
5160 .name = exe_name ,
5261 .root_source_file = b .path ("src/sdl-zig-demo.zig" ),
5362 .target = target ,
@@ -65,7 +74,7 @@ pub fn build(b: *std.Build) void {
6574 .optimize = .ReleaseFast ,
6675 .target = target ,
6776 });
68- if (target .result .os .tag == .linux and ! target .result .isAndroid () ) {
77+ if (target .result .os .tag == .linux and target .result .abi != .android ) {
6978 // The SDL package doesn't work for Linux yet, so we rely on system
7079 // packages for now.
7180 exe .linkSystemLibrary ("SDL2" );
@@ -75,22 +84,16 @@ pub fn build(b: *std.Build) void {
7584 exe .linkLibrary (sdl_lib );
7685 }
7786
78- // NOTE(jae): 2024-09-22
79- // Load additional dynamic libraries that SDLActivity.java loads such as hidapi
80- if (target .result .isAndroid ()) {
81- exe .linkLibrary (sdl_dep .artifact ("hidapi" ));
82- }
83-
8487 const sdl_module = sdl_dep .module ("sdl" );
8588 exe .root_module .addImport ("sdl" , sdl_module );
8689 }
8790
8891 // if building as library for Android, add this target
8992 // NOTE: Android has different CPU targets so you need to build a version of your
9093 // code for x86, x86_64, arm, arm64 and more
91- if (target .result .isAndroid () ) {
94+ if (target .result .abi == .android ) {
9295 const apk : * android.APK = android_apk orelse @panic ("Android APK should be initialized" );
93- const android_dep = b .dependency ("zig- android-sdk " , .{
96+ const android_dep = b .dependency ("android" , .{
9497 .optimize = optimize ,
9598 .target = target ,
9699 });
0 commit comments