Skip to content

Commit e9dc54f

Browse files
Fix issue on Windows where you get an internal error because "android_sdk_path.len == 0" (#29)
fix issue on Windows where you get an internal error because "android_sdk_path.len == 0"
1 parent 18348b6 commit e9dc54f

File tree

3 files changed

+21
-16
lines changed

3 files changed

+21
-16
lines changed

examples/minimal/build.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub fn build(b: *std.Build) void {
2121
}
2222
const android_tools = android.Tools.create(b, .{
2323
.api_level = .android15,
24-
.build_tools_version = "35.0.0",
24+
.build_tools_version = "35.0.1",
2525
.ndk_version = "29.0.13113456",
2626
});
2727
const apk = android.APK.create(b, android_tools);

examples/sdl2/build.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub fn build(b: *std.Build) void {
2222
}
2323
const android_tools = android.Tools.create(b, .{
2424
.api_level = .android15,
25-
.build_tools_version = "35.0.0",
25+
.build_tools_version = "35.0.1",
2626
.ndk_version = "29.0.13113456",
2727
// NOTE(jae): 2025-03-09
2828
// Previously this example used 'ndk' "27.0.12077973".

src/androidbuild/tools.zig

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,24 @@ pub fn create(b: *std.Build, options: Options) *Tools {
133133
var errors = std.ArrayList([]const u8).init(b.allocator);
134134
defer errors.deinit();
135135

136+
if (jdk_path.len == 0) {
137+
errors.append(
138+
\\JDK not found.
139+
\\- Download it from https://www.oracle.com/th/java/technologies/downloads/
140+
\\- Then configure your JDK_HOME environment variable to where you've installed it.
141+
) catch @panic("OOM");
142+
}
143+
if (android_sdk_path.len == 0) {
144+
errors.append(
145+
\\Android SDK not found.
146+
\\- Download it from https://developer.android.com/studio
147+
\\- Then configure your ANDROID_HOME environment variable to where you've installed it."
148+
) catch @panic("OOM");
149+
}
150+
if (errors.items.len > 0) {
151+
printErrorsAndExit("unable to find required Android installation", errors.items);
152+
}
153+
136154
// Get commandline tools path
137155
// - 1st: $ANDROID_HOME/cmdline-tools/bin
138156
// - 2nd: $ANDROID_HOME/tools/bin
@@ -170,20 +188,7 @@ pub fn create(b: *std.Build, options: Options) *Tools {
170188
break :cmdlineblk cmdline_tools;
171189
};
172190

173-
if (jdk_path.len == 0) {
174-
errors.append(
175-
\\JDK not found.
176-
\\- Download it from https://www.oracle.com/th/java/technologies/downloads/
177-
\\- Then configure your JDK_HOME environment variable to where you've installed it.
178-
) catch @panic("OOM");
179-
}
180-
if (android_sdk_path.len == 0) {
181-
errors.append(
182-
\\Android SDK not found.
183-
\\- Download it from https://developer.android.com/studio
184-
\\- Then configure your ANDROID_HOME environment variable to where you've installed it."
185-
) catch @panic("OOM");
186-
} else {
191+
{
187192
// Check if build tools path is accessible
188193
// ie. $ANDROID_HOME/build-tools/35.0.0
189194
std.fs.accessAbsolute(build_tools_path, .{}) catch |err| switch (err) {

0 commit comments

Comments
 (0)