The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 08:30 UTC
fix(server): Android SDK detection looks past an ANDROID_HOME that is not an SDK (#38278)
Julius Marminge committed
Nov 17, 2026 at 11:07 UTC
6ab633f6d6e8273f08a060137ab64463638787ce
2 files changed
+37
-24
apps/server/src/device/LocalDeviceHost.test.ts
+17
@@ -549,6 +549,23 @@ describe("Android SDK availability", () => {
549
}),
550
);
551
552
+ // regression: #38268 an ANDROID_HOME that is not an SDK must not stop detection
553
+ it.effect("falls back past an ANDROID_HOME that is not an SDK", () =>
554
+ Effect.gen(function* () {
555
+ const complete = [
556
+ "/parent/sdk/platform-tools/adb",
557
+ "/parent/sdk/emulator/emulator",
558
+ "/parent/sdk/cmdline-tools/latest/bin/avdmanager",
559
+ ];
560
+ for (const environment of [
561
+ { ANDROID_HOME: "/parent", ANDROID_SDK_ROOT: "/parent/sdk" },
562
+ { ANDROID_HOME: "/parent", PATH: "/parent/sdk/platform-tools" },
563
+ ]) {
564
+ expect(yield* diagnose(complete, environment)).toBeNull();
565
+ }
566
+ }),
567
+ );
568
+
569
it.effect("discovers the standard macOS SDK without ANDROID_HOME", () =>
570
Effect.gen(function* () {
571
const root = "/test/home/Library/Android/sdk";
apps/server/src/device/LocalDeviceHost.ts
+20
-24
@@ -133,7 +133,9 @@ const androidSdk = Effect.gen(function* () {
133
const platform = yield* HostProcess.Platform;
134
const windows = platform === "win32";
135
const home = environment.HOME ?? environment.USERPROFILE ?? "";
136
- const explicit = environment.ANDROID_HOME?.trim() || environment.ANDROID_SDK_ROOT?.trim();
136
+ const explicit = [environment.ANDROID_HOME?.trim(), environment.ANDROID_SDK_ROOT?.trim()].filter(
137
+ (root): root is string => !!root,
138
+ );
139
const exists = (file: string) => fs.exists(file).pipe(Effect.orElseSucceed(() => false));
140
const adbBinary = windows ? "adb.exe" : "adb";
141
const avdmanagerBinary = windows ? "avdmanager.bat" : "avdmanager";
@@ -142,7 +144,6 @@ const androidSdk = Effect.gen(function* () {
144
const emulator = yield* exists(
145
path.join(root, "emulator", windows ? "emulator.exe" : "emulator"),
146
);
145
- if (!explicit && !adb && !emulator) return null;
147
const avdmanager = yield* exists(
148
path.join(root, "cmdline-tools", "latest", "bin", avdmanagerBinary),
149
);
@@ -150,33 +151,28 @@ const androidSdk = Effect.gen(function* () {
151
!avdmanager && (yield* exists(path.join(root, "tools", "bin", avdmanagerBinary)));
152
return { root, adb, emulator, avdmanager, legacyAvdmanager };
153
});
153
- const candidates = explicit
154
- ? [explicit]
155
- : [
156
- path.join(home, "Library", "Android", "sdk"),
157
- path.join(home, "Android", "Sdk"),
158
- path.join(
159
- environment.LOCALAPPDATA ?? path.join(home, "AppData", "Local"),
160
- "Android",
161
- "Sdk",
162
- ),
163
- ];
154
+ const candidates = [
155
+ ...explicit,
156
+ path.join(home, "Library", "Android", "sdk"),
157
+ path.join(home, "Android", "Sdk"),
158
+ path.join(environment.LOCALAPPDATA ?? path.join(home, "AppData", "Local"), "Android", "Sdk"),
159
+ ];
160
for (const root of candidates) {
161
const sdk = yield* inspect(root);
166
- if (sdk) return sdk;
162
+ if (sdk.adb || sdk.emulator) return sdk;
163
}
164
// PATH entries can be slow to stat (network shares), so only consult them after the standard locations miss.
169
- if (!explicit) {
170
- const searchPath = environment.PATH ?? environment.Path ?? "";
171
- for (const directory of searchPath.split(windows ? ";" : ":")) {
172
- if (!directory) continue;
173
- const adb = path.join(directory, adbBinary);
174
- if (!(yield* exists(adb))) continue;
175
- const resolved = yield* fs.realPath(adb).pipe(Effect.orElseSucceed(() => adb));
176
- const sdk = yield* inspect(path.dirname(path.dirname(resolved)));
177
- if (sdk) return sdk;
178
- }
165
+ const searchPath = environment.PATH ?? environment.Path ?? "";
166
+ for (const directory of searchPath.split(windows ? ";" : ":")) {
167
+ if (!directory) continue;
168
+ const adb = path.join(directory, adbBinary);
169
+ if (!(yield* exists(adb))) continue;
170
+ const resolved = yield* fs.realPath(adb).pipe(Effect.orElseSucceed(() => adb));
171
+ const sdk = yield* inspect(path.dirname(path.dirname(resolved)));
172
+ if (sdk.adb || sdk.emulator) return sdk;
173
}
174
+ // No real SDK anywhere: report what the configured root is missing.
175
+ if (explicit[0]) return yield* inspect(explicit[0]);
176
return { root: null, adb: false, emulator: false, avdmanager: false, legacyAvdmanager: false };
177
});
178