Ionic + Cordova Android build error - could not find tools.jar

久未见 提交于 2020-12-05 11:57:08

问题


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.

回答1:


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 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).

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

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.




回答2:


If this is not still resolved for the Cordova android build -- just do it manually. My case: java_home is set properly and also reloaded ~/.zshrc (or ~/.bashrc) files. And I am getting JAVA_HOME value by echoing on terminal.

So I manually copied file tool.jar from /Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home/lib to /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/lib And It worked.

For ease use this cmd

sudo cp /Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home/lib/tools.jar /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/lib

Just check your JAVA JDK version.




回答3:


After updating Mac Os to Big Sur I faced the same problem, Solution :

  • Download the latest JDK 8 from : https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html
  • and Installed it


来源:https://stackoverflow.com/questions/64856188/ionic-cordova-android-build-error-could-not-find-tools-jar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!