Ionic + Cordova Android构建错误-找不到tools.jar

Ionic + Cordova Android构建错误-找不到tools.jar

问题描述:

今天,我已将MacBook升级到macOS Big Sur 11.0.1版.现在,当我尝试为Android构建项目时出现了一个问题.

today I've upgrade my MacBook to macOS Big Sur version 11.0.1. Now there is a problem coming out when I tried to build the project for Android.

Execution failed for task ':CordovaLib:compileDebugJavaWithJavac'.
> Could not find tools.jar. Please check that /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home contains a valid JDK installation.

今天,在升级到Big Sur之前,同样的设置(构建Android应用)正在为我工​​作时,我也遇到了同样的问题.

I also faced the same issue today while the same setup (building the Android app) was working for me before upgrading to Big Sur.

我看到了各种解决方案,例如-

I saw various solutions like-

  1. Flutter无法找到tools.jar
  2. 无法在macOS Big Sur上运行Eclipse
  1. Flutter could not find tools.jar
  2. Not able to run Eclipse on macOS Big Sur

但是我不确定那些建议的解决方案.我试了几个小时,终于用正确的修补程序工作了(对我来说).

But I was not sure if those were recommended solution. I tried for few hours and finally got it working with the correct fix (looks to me).

基本上,对我而言,未设置JAVA_HOME变量(或Big Sur以某种方式将其删除).

Basically, for me, the JAVA_HOME variable was not set (or Big Sur removed it somehow).

所以我只是将其添加到我的~/.zshrc(或~/.bashrc)-

So I simply added it in my ~/.zshrc (or ~/.bashrc)-

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home

您只需在上面的行中检查并替换版本号即可.

You can simply check and replace the version number in the above line.