sharex/xerahs/build-android
Claude Code and agent skill by sharex/xerahs
- community
- ext:[{"type":"hook","description":"Pre/post lifecycle hooks"}]
Checking that the SKILL.md file is still in the repository.
Build and deploy XerahS Android apps (Kotlin/Mobile.Kt, Avalonia, or MAUI) through Gradle, dotnet, and adb. Use only for Android build or deployment work.
Install
npx vskill@latest install sharex/xerahs/build-androidSemi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard
SKILL.md
The same SKILL.md was published earlier as sharex/xerahs/build-android.
You are an expert Android build and deploy specialist for XerahS mobile (Kotlin/Mobile.Kt, Avalonia, and MAUI).
Follow these instructions when building or deploying Android apps. Treat elapsed time as a diagnostic signal, not a fixed failure threshold; stop only when progress is genuinely stalled.
<task> <goal>Build XerahS.Mobile.Ava or XerahS.Mobile.Maui for Android and deploy via adb.</goal> <goal>Avoid file locks by using single-node builds and releasing only verified task-owned lock holders.</goal> <goal>If a build is genuinely stalled, stop and fix locks, parallelism, or stale processes before retrying.</goal> <goal>Ensure MAUI APK works when installed via adb (EmbedAssembliesIntoApk).</goal> </task>
<context> <scripts> <maui>build/android/build-and-deploy-android-maui.ps1</maui> <ava>build/android/build-and-deploy-android-ava.ps1</ava> </scripts> <package_id>com.getsharex.xerahs</package_id> <package_id_kt>com.getsharex.xerahs.mobile</package_id_kt> <adb_default>%LOCALAPPDATA%\Android\Sdk\platform-tools\adb.exe (adb is often not in PATH; use full path)</adb_default> <maui_apk>src\mobile-experimental\XerahS.Mobile.Maui\bin\Debug\net11.0-android\com.getsharex.xerahs-Signed.apk</maui_apk> <ava_apk_dir>src\mobile-experimental\XerahS.Mobile.Ava\bin\Debug\net11.0-android</ava_apk_dir> <kt_project_root>src\mobile\android</kt_project_root> <kt_apk>src\mobile\android\app\build\outputs\apk\debug\app-debug.apk</kt_apk> </context>
Shared Build Guardrails
Before Android-specific work, follow build-common for shared stalled-build recovery, no-concurrent-build, -m:1, TFM, and SkiaSharp rules. This Android skill owns Android-specific prerequisites, emulator/device handling, APK output paths, and deploy commands.
Kotlin (src/mobile/android): prerequisites and first-build lessons
The Kotlin app uses Gradle (not dotnet). The project root is `src/mobile/android` (where settings.gradle.kts and gradlew.bat live).
1. JAVA_HOME is required
First build often fails with: JAVA_HOME is not set and no 'java' command could be found in your PATH.
- Gradle needs a JDK. On Windows, adb and java are often not in PATH; the IDE uses the embedded JBR.
- Fix: Set
JAVA_HOMEto the JDK used by Android Studio before running Gradle, then run the build in the same process (e.g. one PowerShell command that sets env and invokes gradlew):
- If the repo is under a path with spaces (e.g.
ShareX Team\XerahS), use quoted paths and ensurecdis to the Kotlin project root.
2. Compose KeyboardOptions: correct import and dependency
Symptom: Unresolved reference: KeyboardOptions when compiling a module that uses KeyboardOptions in a Compose TextField/OutlinedTextField.
- Wrong:
import androidx.compose.ui.text.input.KeyboardOptions— that package does not exposeKeyboardOptionsin the way the compiler resolves for the dependency set in use. - Right:
import androidx.compose.foundation.text.KeyboardOptions.KeyboardCapitalizationstaysandroidx.compose.ui.text.input.KeyboardCapitalization;KeyboardTypeisandroidx.compose.ui.text.input.KeyboardType.
- Module dependency: The module that uses
KeyboardOptions(e.g.feature:settings) must depend on Compose Foundation, or the build will still fail with "Unresolved reference: KeyboardOptions". In that module’sbuild.gradle.kts:
- URL / no auto-capitalize: For URL or domain fields, use
KeyboardType.Uritogether withKeyboardCapitalization.Noneso the soft keyboard does not auto-capitalize; some IMEs ignore capitalization when the type is alreadyUri.
3. adb not in PATH
Symptom: The term 'adb' is not recognized when running install or logcat from a script or terminal.
- Use the full path to adb, e.g.
$env:LOCALAPPDATA\Android\Sdk\platform-tools\adb.exe, or setANDROID_HOME/PATHso thatadbis found. The build skill assumes adb is invoked via full path when PATH is not configured.
4. Kotlin build and deploy (summary)
| Step | Command / path | |
|---|---|---|
| Project root | src\mobile\android | |
| Build | Set JAVA_HOME then .\gradlew.bat assembleDebug | |
| APK | app\build\outputs\apk\debug\app-debug.apk | |
| Install | adb install -r <path-to-app-debug.apk> |
Pre-build: release locks
File locks are the main cause of Android build failures. Before building, ensure no previous build is still running and clean can run.
1. Identify what is locked
- Clean fails with
The process cannot access the file '...' because it is being used by another process. The message often says which process (e.g..NET Host (27788)orVBCSCompiler). - Build fails with
CompileAvaloniaXamlTask/Cannot open '...ShareX.ImageEditor.dll' for writingor...XerahS.AmazonS3.Plugin.dll ... being used by another process— usually parallel MSBuild racing on the same output. - Build fails with
XA0142/llvm-objcopy.EXE: error: permission deniedor `XAWAS7024: The file is locked by: ".NET Host (PID)" on paths likeobj\Debug\net11.0-android\android-arm64\wrapped\lib_*.dll.so— a previous build’s .NET Host is still holding wrapped assembly outputs. Stop that PID, then clean and rebuild.
2. Release the lock and build single-node
Stop only the verified task-owned lock holder, as in build-common. Never run two Android or solution builds at once: ShareX.ImageEditor and the AmazonS3 plugin share outputs and wrapped .so files. Both build-and-deploy-android-maui.ps1 and build-and-deploy-android-ava.ps1 use -m:1; do not remove it. Manual builds use dotnet build <project> -f net11.0-android -c Debug -m:1.
3. Clean after releasing locks
After stopping the locking process:
If clean still fails, manually remove obj folders that are locked (e.g. ShareX.ImageEditor\src\ShareX.ImageEditor\obj, src\desktop\plugins\AmazonS3.Plugin\obj, src\mobile-experimental\XerahS.Mobile.Ava\obj\Debug\net11.0-android, or the MAUI obj\Debug\net11.0-android if the APK is locked).
Cold-boot emulator (optional)
To start an Android emulator with a cold boot (no snapshot load) before building/deploying:
- List AVDs:
& "$env:LOCALAPPDATA\Android\Sdk\emulator\emulator.exe" -list-avds - Start emulator:
Start-Process -FilePath $emulator -ArgumentList "-avd","<AVD_NAME>","-no-snapshot-load" -WindowStyle Normal - Wait for device: Poll until
adb devicesshows a line ending withdevice(e.g. up to 120 s). The build script will fail with "No emulator/device attached" if no device is present when it runs the install step. - Then run the build-and-deploy script. If the emulator is closed or disconnects during the 2–5 minute build, run
adb devicesagain and restart the emulator if needed before re-running only the deploy (manual install/launch below).
MAUI-specific: EmbedAssembliesIntoApk
When the MAUI app is installed via adb install (not via Visual Studio deploy), the APK must contain the .NET assemblies. By default, Debug uses Fast Deployment, which omits assemblies from the APK and pushes them via the IDE; so a standalone adb install -r results in "No assemblies found" and the app crashes after the splash.
- Fix: In
XerahS.Mobile.Maui.csproj, set `EmbedAssembliesIntoApk` to `true` for Android (already done). Then rebuild; the APK will be larger and work with adb install. - Trade-off: Build is slightly slower; no change to behavior once embedded.
MAUI white screen / init
If the MAUI app shows a white screen after the logo (similar to the old Avalonia "stuck" issue):
- Cause: The loading page has not painted before heavy init runs (or with
EmbedAssembliesIntoApk, first frame is slower). Starting init too soon leaves the user seeing a blank screen. - Fix: In
MainActivity.cs, defer callingInitializeCoreAsyncby ~400 ms (e.g.Task.Run+Task.Delay(400)+MainThread.BeginInvokeOnMainThread). Do not call it immediately inOnCreate. Seedevelopers/lessons-learnt/android_avalonia_init_fix.md(MAUI section).
Avalonia-specific: host Content
Avalonia Android had a bug where `parent.Content = null` in MainActivity cleared the host of MainView, so the whole UI disappeared even though init and navigation completed. Do not set the host’s Content to null. See developers/lessons-learnt/android_avalonia_init_fix.md.
Build and deploy commands
Kotlin (src/mobile/android)
Set JAVA_HOME and build from the Kotlin project root (see "Kotlin: prerequisites and first-build lessons" above). Then install with adb (full path if adb is not in PATH).
Install and optionally launch:
If the first build fails with JAVA_HOME or KeyboardOptions, apply the fixes in the Kotlin section above before retrying.
MAUI (recommended: use script)
- Script uses `-m:1` and runs clean (if
-Clean), build, then adb install and launch. - Timeout: Do not use a fixed cap; stop only when output or process state shows the build is stalled.
Avalonia
The Avalonia script always uses `-m:1` to avoid file locks. Ensure an emulator or device is attached (adb devices) before running; the script checks for a device only at deploy time, so if the emulator was closed during the build, start it again and run manual install/launch below.
Manual install and launch (when APK already exists)
Use when the APK is already built but deploy failed (e.g. no device at script run time), or to re-launch without rebuilding. Set $adb from ANDROID_HOME or %LOCALAPPDATA%\Android\Sdk if needed.
MAUI:
Avalonia:
Success criteria
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryChecking.ai/skills/build-android/SKILL.md
Popularity
- Repository stars
- 242
- Repository forks
- 11
- 7-day trend score
- 27
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 3 May 2026, 6 months ago.
Extension points
hookPre/post lifecycle hooks
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/sharex/xerahs/build-android)