Mac中Ionic+Cordova Android打包報錯Could not find tools.jar. Please check that /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home contains a valid JDK installation.


1、報錯信息如下(該報錯的意思是在目錄下沒有找到tools.jar文件):

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.

2、解決方法(在終端Terminal中執行以下命令)

先通過如下命令查看JDK位置

/usr/libexec/java_home -V             #(升級OSX11.0.1后,執行這個命令可能看到兩個路徑,一個是JDK的實際路徑,另一個是:/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home,(網上有資料說這個是JRE的路徑)。

解決方法一:

vim ~/.bash_profile    #~/.bash_profile不存在則創建
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Home            #在打開的bash_profile中添加這一句並保存退出編輯模式
source ~/.bash_profile    #讓這個配置文件在修改后立即生效

解決方法二:手動復制 tools.jar

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

注:根據自己的實際JDK路徑修改上面的JDK路徑

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM