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

无法构建Cordova应用:JDK版本检测失败问题求助

Fix: JDK 1.8.2 Requirement Error in Ionic 3 + Cordova (With JDK 9 Installed)

Why This Happens

I've run into this exact snag back when working with Ionic 3 and older Cordova versions—here's the deal: Ionic 3 and its dependent Cordova tooling have strict compatibility with JDK 8 (1.8.x). JDK 9 introduced breaking changes to APIs and module systems that the older build tools simply don't support, which is why you're hitting the requirement check failure even with a newer JDK installed.

Solutions to Try

1. Install JDK 8 and Set It as Default (Recommended)

This is the most reliable fix since it aligns perfectly with what the tooling expects:

  • Grab JDK 8 (either Oracle JDK 8 or OpenJDK 8 works) and install it on your system.
  • Configure your environment variables:
    • Set JAVA_HOME to the installation path of JDK 8 (e.g., C:\Program Files\Java\jdk1.8.0_xxx on Windows, /Library/Java/JavaVirtualMachines/jdk1.8.0_xxx.jdk/Contents/Home on macOS).
    • Add the JDK 8 bin directory to the front of your PATH variable to make sure it takes priority over JDK 9.
  • Verify the change: Open a fresh terminal/command prompt and run:
    java -version
    javac -version
    
    Both should output a version starting with 1.8.x.

2. Switch Between JDK Versions (If You Need JDK 9 for Other Projects)

If you don't want to uninstall JDK 9, you can set up quick version switching:

  • Windows:
    • Create environment variables like JAVA_HOME_8 (pointing to JDK 8) and JAVA_HOME_9 (pointing to JDK 9).
    • Use a batch script to toggle JAVA_HOME and PATH when working on your Ionic 3 project, or manually edit the environment variables temporarily.
  • macOS/Linux:
    • Add aliases to your shell config file (e.g., ~/.bashrc, ~/.zshrc) to switch fast:
      alias jdk8='export JAVA_HOME=/path/to/jdk8'
      alias jdk9='export JAVA_HOME=/path/to/jdk9'
      
    • Run jdk8 in your terminal before building the Ionic app to use JDK 8 for that session.

3. Double-Check Cordova and Android SDK Compatibility

While the JDK version is the main culprit, keep in mind Ionic 3 is an older framework:

  • Make sure your Android SDK targets a compatible version (typically Android 8.0/8.1, SDK level 26 or 27).
  • Skip the latest Android SDK tools—they often don't play nice with older Cordova versions.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.19 07:15:43