Skip to content

Commit 46de098

Browse files
Added android sdk path update function
1 parent f298a21 commit 46de098

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

Framework/install_handler/android/android_sdk.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,39 @@ def get_adb_path():
6363
else:
6464
return sdk_root / "platform-tools" / "adb"
6565

66+
67+
def update_android_sdk_path():
68+
"""Add Android SDK paths to PATH and set ANDROID_HOME for the current process (following Node.js pattern)."""
69+
sdk_root = _get_sdk_root()
70+
71+
# Check if SDK exists
72+
adb_path = get_adb_path()
73+
if not adb_path.exists():
74+
print("[installer][android-sdk] Warning: Android SDK not found for PATH update.")
75+
return
76+
77+
# Set ANDROID_HOME and ANDROID_SDK_ROOT for current process
78+
os.environ['ANDROID_HOME'] = str(sdk_root)
79+
os.environ['ANDROID_SDK_ROOT'] = str(sdk_root)
80+
print(f"[installer][android-sdk] ANDROID_HOME set for current process: {sdk_root}")
81+
82+
# Add SDK paths to PATH for current process (prepend so they take precedence)
83+
sdk_paths = [
84+
str(sdk_root / "platform-tools"),
85+
str(sdk_root / "emulator"),
86+
str(sdk_root / "cmdline-tools" / "latest" / "bin"),
87+
]
88+
89+
current_path = os.environ.get('PATH', '')
90+
for sdk_path in sdk_paths:
91+
if sdk_path not in current_path:
92+
os.environ['PATH'] = f"{sdk_path}{os.pathsep}{current_path}"
93+
current_path = os.environ['PATH']
94+
print(f"[installer][android-sdk] Added to current process PATH: {sdk_path}")
95+
else:
96+
print(f"[installer][android-sdk] Already in PATH: {sdk_path}")
97+
98+
6699
def _get_cmdline_tools_url() -> str:
67100
version = "10406996_latest"
68101
system = platform.system()

0 commit comments

Comments
 (0)