Install
openclaw skills install @oahc09/android-project-generatorGenerate Android projects that compile on the first real build, including optional JNI/NDK/CMake native setup. Use when creating new Android apps, configuring Gradle and version compatibility, validating assembleDebug readiness, or adding native modules.
openclaw skills install @oahc09/android-project-generatorEnsure AI-generated Android projects compile successfully on the first attempt by providing:
Before using this skill on a production or sensitive machine, verify:
python, java, and at least one of gradle/gradlew.JAVA_HOME (recommended), ANDROID_HOME or ANDROID_SDK_ROOT, optional ANDROID_NDK_HOME or NDK_HOME for native workflows.adb install, adb shell am start) are allowed for connected devices/emulators.This skill runs local commands and may perform build/device operations; treat it as operational code, not documentation-only guidance. It does not request API keys, tokens, or cloud credentials by design.
This skill does not require cloud credentials, API keys, or tokens.
It does rely on local environment variables and installed binaries/tooling:
JAVA_HOME, ANDROID_HOME/ANDROID_SDK_ROOT, and for native projects ANDROID_NDK_HOME/NDK_HOME.java, gradle/gradlew, Android SDK/NDK on disk, and optional adb for install/launch verification.The scripts do not intentionally exfiltrate data, but they do run subprocesses that may:
adb)Trigger this skill when:
build.gradle.kts, settings.gradle.kts)JNI, NDK, CMake, externalNativeBuild)If the project is meant to build on the current machine, do not generate files yet. Audit the environment first:
python scripts/detect_env.py
Treat this phase as mandatory for local project generation because most "AI generated Android project won't compile" failures are environment mismatches, not template mistakes.
This outputs:
JAVA_HOME configuration and versionPATH java executable and versionJAVA_HOME vs PATH)If ready_for_build is false:
If the environment status is degraded:
JAVA_HOME is missing, so Gradle is falling back to PATHBase the profile on audited environment data, not guesswork:
| Profile | AGP | Gradle | JDK | Use Case |
|---|---|---|---|---|
| stable | 8.7.0 | 8.9 | 17+ | Recommended for most projects |
| latest | 9.1.0 | 9.3.1 | 17+ | New features, Android 16+ |
| legacy | 7.4.2 | 7.5 | 11+ | Older environments |
Default to "stable" profile only when the environment is ready for it.
Use this decision order:
platforms/android-35, and build-tools are present → use stablelatestlegacyNative 触发策略(native_enabled):
native_enabled = falseJNI、NDK、CMake、externalNativeBuild、C++、native library、原生模块)→ 自动切到 native_enabled = truenative、底层、性能优化)→ 先标记候选并二次确认,再决定是否开启native_enabled=true/false),显式配置优先于关键词推断Additional JDK rules:
JAVA_HOME over an accidental PATH javaJAVA_HOME and PATH java disagree, treat that as a reproducibility risk and explain itAlways create the complete file structure:
ProjectName/
├── settings.gradle.kts
├── build.gradle.kts
├── gradle.properties
├── gradle/
│ └── wrapper/
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── app/
│ ├── build.gradle.kts
│ ├── src/
│ │ └── main/
│ │ ├── AndroidManifest.xml
│ │ ├── java/com/example/project/
│ │ │ └── MainActivity.kt
│ │ └── res/
│ │ ├── layout/
│ │ │ └── activity_main.xml
│ │ ├── values/
│ │ │ ├── strings.xml
│ │ │ └── themes.xml
│ │ └── mipmap-*/
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ └── proguard-rules.pro
└── local.properties (create when sdk path is known and immediate CLI build is expected)
Important:
local.properties with sdk.dir=... to reduce local environment ambiguityGRADLE_LOCAL_JAVA_HOME or equivalent project-scoped JDK bindingLoad templates from references/config-templates.md:
MyApp, com.example.myapp, com.example.myapp.MainActivitynamespace, applicationId, source package path, and theme names alignedlocal.propertiesBefore reporting the project as buildable, ensure the wrapper is genuinely usable:
gradlewgradlew.batgradle/wrapper/gradle-wrapper.propertiesgradle/wrapper/gradle-wrapper.jargradle-wrapper.properties file alone is not enoughUse one of these approaches:
gradle wrapper --gradle-version <target-version> if Gradle is installedassembleDebugYou can use scripts/project_validator.py logic as the acceptance bar:
After generating all files, MUST run:
./gradlew assembleDebug
If compilation fails:
references/version-matrix.mdassembleDebug passes with the generated projectIf the wrapper is unavailable or the environment is missing mandatory SDK components:
After assembleDebug, verify that the debug APK really exists:
app/build/outputs/apk/debug/app-debug.apk
Use scripts/build_flow.py concepts as the final status model:
scaffolding_only
build_failed
assembleDebug failed or no APK was producedcompiled
assembleDebug succeeded and the debug APK existsIf a device or emulator is available, continue one more step:
runnableAdditional final states:
install_failed
launch_failed
runnable
Only the compiled state should be described as:
Only the runnable state should be described as:
See references/version-matrix.md for:
Key rules:
See references/config-templates.md for:
settings.gradle.kts templatebuild.gradle.ktsgradle.properties defaultsgradle-wrapper.properties formatMainActivity.kt and AndroidManifest.xmlscripts/detect_env.py provides:
java -version output)Run this script to adapt the generated project to the user's actual environment.
./gradlew assembleDebugbuild.gradle.ktslocal.properties when immediate local CLI build is required and sdk path is knownJAVA_HOME, Android Studio Gradle JDK, and project-level Gradle JDK settingsgradle/libs.versions.toml for larger projects| Mistake | Fix |
|---|---|
Missing namespace in app/build.gradle.kts | Add namespace = "com.example.myapp" in android {} block |
| Wrong JDK version for AGP 8.x | Use AGP 7.x if JDK < 17, or instruct user to install JDK 17 |
| Inconsistent AGP/Gradle versions | Check version-matrix.md, use recommended pairs |
| Missing or fake Gradle Wrapper files | Always include gradlew, gradlew.bat, gradle-wrapper.properties, and gradle-wrapper.jar |
Wrong compileSdk for AGP version | AGP 8.7+ requires compileSdk = 35, AGP 9.x requires compileSdk = 36 |
| Missing SDK platform or build-tools | Check environment audit before generation; install missing SDK components first |
| Build verified only in theory | Do not claim success without a real assembleDebug run |
JAVA_HOME missing but PATH java exists | Treat as degraded, not fully stable; recommend explicit JDK configuration |
JAVA_HOME and PATH java point to different JDKs | Explain that Gradle CLI will prefer JAVA_HOME, which can differ from shell expectations |
assembleDebug succeeded but no APK found | Treat as build verification failure until app-debug.apk is confirmed |
| APK exists but install fails | Treat as install_failed; do not claim the app is runnable |
| Install succeeds but launch fails | Treat as launch_failed; do not claim runtime verification passed |
User: "Create a new Android project called TodoApp"
AI Response:
detect_env.py (if possible)MyApp → TodoApp, com.example.myapp → com.example.todoapp./gradlew assembleDebugapp/build/outputs/apk/debug/app-debug.apk existscompiled only if build + APK verification passrunnable only if build + install + launch all passThis skill transforms Android project generation from a guessing game into an audited, verifiable build process.