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

构建Ionic Android应用时遇Cannot read property '1' of null错误求助

解决Ionic Cordova Android构建报错:TypeError: Cannot read property '1' of null

Hey there! I’ve seen this exact error pop up when there’s a mismatch between your Cordova version and JDK setup, so let’s break this down and fix it together.

问题根源

Your setup has a critical compatibility issue: Cordova 6.0 does not support JDK 10.1. Cordova 6.x was released back when JDK 8 was the standard, and it can’t handle the versioning changes introduced in JDK 9+. That "Cannot read property '1' of null" error is Cordova’s way of failing to parse the newer JDK version information.

分步解决方案

  • 降级JDK到版本8: This is the core fix. Uninstall JDK 10.1 and install JDK 8 (either Oracle JDK 8 or OpenJDK 8 works—just make sure it’s a full JDK, not just JRE).
  • 更新环境变量配置:
    • Set JAVA_HOME to point to the root directory of your JDK 8 installation (e.g., C:\Program Files\Java\jdk1.8.0_301 on Windows, /Library/Java/JavaVirtualMachines/jdk1.8.0_301.jdk/Contents/Home on Mac).
    • Add the JDK 8 bin folder to your system PATH variable to ensure the CLI picks up the correct version.
  • 验证JDK版本: Open a fresh terminal/command prompt and run java -version and javac -version—both should show version 1.8.x.
  • 清理并重新构建项目:
    1. Run ionic cordova clean android to clear cached build files that might be causing conflicts.
    2. Try rebuilding with ionic cordova build android again.
  • 检查Android SDK兼容性: Cordova 6.0 works best with Android SDK Build Tools versions between 23.x and 26.x. Open Android Studio’s SDK Manager and make sure you have one of these versions installed.

If you still hit snags after these steps, double-check that your Ionic 3 and Cordova 6.x versions are in sync (they’re designed to work together, so this shouldn’t be an issue, but it’s worth confirming).

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.29 08:41:44