执行cordova build android --release输出异常且未生成APK
Hey Steve, I’ve run into this exact head-scratcher before—let’s break down why your APK isn’t showing up and how to fix it:
That initial output is just setup info, not an error
The messageAndroid Studio project detected ANDROID_HOME=/Users//Library/Android/sdk JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_73.jdk/Contents/Homeis just Cordova confirming it’s recognized your Android environment and project structure. The actual build process might be failing silently, or the full output got truncated in your terminal.Watch for hidden build errors
Re-run the build commandcordova build android --releaseand keep a close eye for red error messages. Common culprits include:- Missing Android SDK platforms (you might need to install the specific SDK version your project targets)
- Syntax errors or corrupted files in your
wwwfolder - Permission issues accessing the Android SDK directory
Fix your malformed ANDROID_HOME path
Notice the double slash//in your ANDROID_HOME path? It should be/Users/[your-mac-username]/Library/Android/sdk. This broken path could be stopping Cordova from accessing critical SDK tools. Update your environment variables to point to the correct SDK location.Clean cached files before rebuilding
Stale build artifacts often cause weird, silent failures. Run this first to wipe old data:cordova clean androidThen re-run the release build command—this forces a fresh start.
Manually check the output directory
Even if the terminal doesn’t mention it, the APK might already exist! Navigate to this folder in Finder:[your-project-root]/platforms/android/app/build/outputs/apk/release/Look for
app-release-unsigned.apk(you’ll need to sign this file before distributing it).Verify your Java and SDK versions
Your JDK 1.8 might be outdated for newer Cordova versions. Check your Cordova version withcordova -vand confirm it supports JDK 1.8—many recent releases require JDK 11. Also, make sure you have the latest Android SDK Build Tools installed via Android Studio.
内容的提问来源于stack exchange,提问作者Steve

