You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

执行ionic cordova run android时JDK版本检测报错求助

Fixing Cordova's JDK 1.8+ Requirements Check Failure

Hey there, let's work through this issue you're facing. Even though you've set up JAVA_HOME to point to JDK 9.0.4 and ANDROID_HOME correctly, Cordova is still throwing that frustrating JDK version error. Here are some targeted steps to resolve this:

1. Verify Your Environment Variables Are Actually Active

First off, environment variable changes often require a fresh terminal window to take effect. Open a new Command Prompt and run these commands to double-check:

  • java -version: Confirm the output shows your JDK 9 version (not an older or unrelated Java installation)
  • echo %JAVA_HOME%: Make sure the path matches exactly C:\Program Files\Java\jdk-9.0.4—even a tiny typo here can break everything

If either check fails, revisit your system environment variables:

  • Ensure JAVA_HOME is set in System Variables (not just User Variables) for global access across all apps
  • Double-check that %JAVA_HOME%\bin is added to your Path variable so the system can find Java executables

2. Try Downgrading to JDK 8 (Java 1.8)

While the error says "1.8 or greater", some older Cordova versions have compatibility quirks with JDK 9+. Java 8 is the most widely tested and recommended version for Cordova Android development right now. Here's how to switch:

  • Download a stable JDK 8 release (you can use Oracle's official build or an open-source alternative like Adoptium)
  • Install it to a clean path like C:\Program Files\Java\jdk1.8.0_301
  • Update your JAVA_HOME environment variable to point to this new path
  • Restart your terminal and run ionic cordova run android again

This is usually the quickest fix for this exact error.

3. Update Your Cordova Android Platform

If you want to stick with JDK 9, make sure your Cordova Android platform is up-to-date enough to support it. Run these commands:

# Check your current Cordova Android platform version
cordova platform ls
# Update to the latest stable Android platform
cordova platform update android

Newer versions of the Cordova Android platform have improved support for newer JDK releases.

4. Address the Unhandled Promise Rejection Warning

That deprecation warning is a side effect of the underlying JDK version error—once you fix the core issue, this warning should disappear on its own. If it lingers, you can add a quick global handler in your project's root JS file to catch unhandled promises (though this is just a band-aid for the warning, not the root problem):

process.on('unhandledRejection', (reason, promise) => {
  console.log('Unhandled Rejection at:', promise, 'Reason:', reason);
});

内容的提问来源于stack exchange,提问作者james watt

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 09:34:53