Skip to content

Commit 66b741b

Browse files
committed
fix issue on Windows where you get an internal error because "android_sdk_path.len == 0"
1 parent 18348b6 commit 66b741b

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

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)