Skip to content

Commit e338f39

Browse files
committed
remove setup_android_tools.py: deprecated script no longer in use; add unit tests for NDK resolver
1 parent 3be7205 commit e338f39

38 files changed

+8600
-802
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,3 +133,5 @@ CLAUDE.md
133133

134134
# Test results
135135
experiments/results/
136+
ovmb_cache
137+
artifacts

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ cat experiments/results/*.csv
3030
- **[User Guide](docs/user-guide.md)** - Complete usage documentation
3131
- **[Configuration Reference](docs/configuration.md)** - YAML configuration schema
3232
- **[Device Setup](docs/device-setup.md)** - Android/Linux device preparation
33+
- **[Android Installer Module](docs/android_installer.md)** - Automated Android SDK/NDK setup
3334
- **[Build Guide](docs/build-guide.md)** - Building OpenVINO for mobile
3435
- **[Benchmarking Guide](docs/benchmarking.md)** - Running and interpreting benchmarks
3536
- **[CI/CD Integration](docs/ci-cd.md)** - GitHub Actions and automation
@@ -46,6 +47,7 @@ cat experiments/results/*.csv
4647
- 🌡️ **Device Control** - Temperature monitoring, performance tuning
4748
- 🔄 **CI/CD Ready** - GitHub Actions integration included
4849
- 📈 **Reproducible** - Full provenance tracking of builds and runs
50+
- 🤖 **Android SDK/NDK Installer** - Automated setup of Android development tools
4951

5052
## 🔧 Supported Platforms
5153

docs/android-setup.md

Lines changed: 113 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -4,95 +4,128 @@ This guide explains how to install Android SDK and NDK for building and running
44

55
## Automated Installation
66

7-
We provide a Python script that automatically downloads and installs Android SDK and NDK for Windows, macOS, and Linux.
7+
The `ovmobilebench.android.installer` module provides a robust, type-safe, and well-tested solution for Android SDK/NDK installation.
88

99
### Prerequisites
1010

11-
- Python 3.7 or higher
12-
- ~5GB of free disk space
11+
- Python 3.8 or higher
12+
- ~15GB of free disk space
1313
- Internet connection for downloading tools
14+
- Java 11+ (for Android tools)
1415

15-
### Installation Script
16+
### Python API
1617

17-
Run the installation script from the project root:
18+
```python
19+
from ovmobilebench.android import ensure_android_tools
20+
21+
# Install Android SDK and NDK
22+
result = ensure_android_tools(
23+
sdk_root="~/android-sdk",
24+
api=30,
25+
target="google_atd",
26+
arch="arm64-v8a",
27+
ndk="r26d",
28+
verbose=True
29+
)
30+
31+
print(f"SDK installed at: {result['sdk_root']}")
32+
print(f"NDK installed at: {result['ndk_path']}")
33+
```
34+
35+
### Command Line Interface
1836

1937
```bash
20-
python scripts/setup_android_tools.py
38+
# Install Android SDK and NDK
39+
ovmobilebench-android-installer setup \
40+
--sdk-root ~/android-sdk \
41+
--api 30 \
42+
--target google_atd \
43+
--arch arm64-v8a \
44+
--ndk r26d
45+
46+
# Verify installation
47+
ovmobilebench-android-installer verify --sdk-root ~/android-sdk
48+
49+
# List available targets
50+
ovmobilebench-android-installer list-targets
2151
```
2252

23-
This will:
24-
1. Fetch the latest available versions from Google's repository
25-
2. Install both Android SDK and NDK to `~/android-sdk` by default
26-
3. Use the most recent stable versions automatically
53+
### Key Features
54+
55+
- ✅ Type-safe with full type hints
56+
- ✅ Comprehensive error handling
57+
- ✅ Dry-run mode for testing
58+
- ✅ Structured logging with JSON Lines support
59+
- ✅ Cross-platform support (Windows, macOS, Linux)
60+
- ✅ Idempotent operations (safe to run multiple times)
61+
- ✅ AVD (Android Virtual Device) management
62+
- ✅ Environment variable export in multiple formats
63+
64+
For complete documentation, see [Android Installer Module Documentation](android_installer.md).
2765

2866
### Installation Options
2967

3068
#### Custom Installation Directory
3169

3270
```bash
33-
python scripts/setup_android_tools.py --install-dir /path/to/install
71+
ovmobilebench-android-installer setup \
72+
--sdk-root /path/to/install \
73+
--api 30 \
74+
--ndk r26d
3475
```
3576

3677
#### Install Only NDK (without SDK)
3778

3879
If you only need NDK for building OpenVINO:
3980

4081
```bash
41-
python scripts/setup_android_tools.py --ndk-only
42-
```
43-
44-
#### List Available Versions
45-
46-
To see all available versions fetched from Google:
47-
48-
```bash
49-
python scripts/setup_android_tools.py --list-versions
82+
ovmobilebench-android-installer setup \
83+
--sdk-root ~/android-sdk \
84+
--api 30 \
85+
--ndk r26d \
86+
--no-platform-tools \
87+
--no-emulator
5088
```
5189

5290
#### Specify Versions
5391

54-
Install specific versions instead of latest:
92+
Install specific versions:
5593

5694
```bash
5795
# Specific NDK version
58-
python scripts/setup_android_tools.py --ndk-version r26d
59-
60-
# Multiple specific versions
61-
python scripts/setup_android_tools.py \
62-
--ndk-version r26d \
63-
--build-tools-version 34.0.0 \
64-
--platform-version 34
65-
```
66-
67-
#### Offline Mode
68-
69-
To skip fetching from Google and use fallback versions:
70-
71-
```bash
72-
python scripts/setup_android_tools.py --no-fetch
96+
ovmobilebench-android-installer setup \
97+
--sdk-root ~/android-sdk \
98+
--api 30 \
99+
--ndk r26d \
100+
--build-tools 34.0.0
73101
```
74102

75-
#### Keep Downloaded Files
103+
#### Dry Run Mode
76104

77-
By default, the script removes downloaded archives after installation. To keep them:
105+
Preview what would be installed without making changes:
78106

79107
```bash
80-
python scripts/setup_android_tools.py --skip-cleanup
108+
ovmobilebench-android-installer setup \
109+
--sdk-root ~/android-sdk \
110+
--api 30 \
111+
--ndk r26d \
112+
--dry-run
81113
```
82114

83115
### What Gets Installed
84116

85117
**Full Installation (default):**
86-
- Android SDK Command Line Tools (latest version)
118+
- Android SDK Command Line Tools
87119
- Android SDK Platform Tools (includes `adb`)
88-
- Android SDK Build Tools (latest version)
89-
- Android Platform API (latest version)
90-
- Android NDK (latest version)
120+
- Android SDK Build Tools
121+
- Android Platform API
122+
- Android NDK
123+
- System Images (for emulator)
124+
- Android Emulator (optional)
91125

92126
**NDK-Only Installation:**
93-
- Android NDK (latest version)
94-
95-
Note: The script automatically fetches and uses the most recent versions from Google's repository. You can see available versions with `--list-versions` or specify specific versions with the version flags.
127+
- Android SDK Command Line Tools (required)
128+
- Android NDK
96129

97130
### Platform-Specific Details
98131

@@ -113,52 +146,48 @@ Note: The script automatically fetches and uses the most recent versions from Go
113146

114147
### Environment Setup
115148

116-
After installation, the script will display environment variables to add to your shell configuration:
117-
118-
#### Linux/macOS (bash/zsh)
149+
After installation, export environment variables using the module:
119150

120-
Add to `~/.bashrc`, `~/.zshrc`, or equivalent:
151+
```python
152+
from ovmobilebench.android import export_android_env
121153

122-
```bash
123-
export ANDROID_SDK_ROOT="$HOME/android-sdk/sdk"
124-
export ANDROID_HOME="$HOME/android-sdk/sdk"
125-
export ANDROID_NDK_ROOT="$HOME/android-sdk/ndk/r26d"
126-
export ANDROID_NDK_HOME="$HOME/android-sdk/ndk/r26d"
127-
export NDK_ROOT="$HOME/android-sdk/ndk/r26d"
128-
export PATH="$HOME/android-sdk/sdk/platform-tools:$HOME/android-sdk/sdk/cmdline-tools/latest/bin:$PATH"
154+
# Get environment variables
155+
env = export_android_env(
156+
sdk_root="~/android-sdk",
157+
ndk_path="~/android-sdk/ndk/26.3.11579264",
158+
format="bash" # or "fish", "windows", "github"
159+
)
160+
print(env)
129161
```
130162

131-
Or source the generated script:
163+
Or use the CLI to generate export commands:
132164

133165
```bash
134-
source ~/android-sdk/android_env.sh
166+
# For bash/zsh
167+
ovmobilebench-android-installer export-env \
168+
--sdk-root ~/android-sdk \
169+
--ndk-path ~/android-sdk/ndk/26.3.11579264 \
170+
--format bash >> ~/.bashrc
171+
172+
# For fish shell
173+
ovmobilebench-android-installer export-env \
174+
--sdk-root ~/android-sdk \
175+
--ndk-path ~/android-sdk/ndk/26.3.11579264 \
176+
--format fish >> ~/.config/fish/config.fish
177+
178+
# For Windows PowerShell
179+
ovmobilebench-android-installer export-env `
180+
--sdk-root C:\android-sdk `
181+
--ndk-path C:\android-sdk\ndk\26.3.11579264 `
182+
--format windows
135183
```
136184

137-
#### Windows (PowerShell)
138-
139-
Add to PowerShell profile:
140-
141-
```powershell
142-
$env:ANDROID_SDK_ROOT = "$env:USERPROFILE\android-sdk\sdk"
143-
$env:ANDROID_HOME = "$env:USERPROFILE\android-sdk\sdk"
144-
$env:ANDROID_NDK_ROOT = "$env:USERPROFILE\android-sdk\ndk\r26d"
145-
$env:ANDROID_NDK_HOME = "$env:USERPROFILE\android-sdk\ndk\r26d"
146-
$env:NDK_ROOT = "$env:USERPROFILE\android-sdk\ndk\r26d"
147-
$env:Path += ";$env:USERPROFILE\android-sdk\sdk\platform-tools"
148-
$env:Path += ";$env:USERPROFILE\android-sdk\sdk\cmdline-tools\latest\bin"
149-
```
150-
151-
#### Windows (Command Prompt)
152-
153-
```batch
154-
set ANDROID_SDK_ROOT=%USERPROFILE%\android-sdk\sdk
155-
set ANDROID_HOME=%USERPROFILE%\android-sdk\sdk
156-
set ANDROID_NDK_ROOT=%USERPROFILE%\android-sdk\ndk\r26d
157-
set ANDROID_NDK_HOME=%USERPROFILE%\android-sdk\ndk\r26d
158-
set NDK_ROOT=%USERPROFILE%\android-sdk\ndk\r26d
159-
set PATH=%PATH%;%USERPROFILE%\android-sdk\sdk\platform-tools
160-
set PATH=%PATH%;%USERPROFILE%\android-sdk\sdk\cmdline-tools\latest\bin
161-
```
185+
The module sets the following environment variables:
186+
- `ANDROID_HOME` - Android SDK root directory
187+
- `ANDROID_SDK_ROOT` - Same as ANDROID_HOME
188+
- `ANDROID_NDK_HOME` - NDK installation directory
189+
- `ANDROID_NDK_ROOT` - Same as ANDROID_NDK_HOME
190+
- `PATH` - Updated with platform-tools and cmdline-tools
162191

163192
### Verification
164193

0 commit comments

Comments
 (0)