我已经搜索了堆栈溢出,但没有找到解决问题的方法。这个有点啰嗦了,不过最近一周没找到解决办法,不停的搜索。
问题:在尝试编译 Android 源代码以及尝试安装 Android Studio 时未找到 tools.jar
操作系统:Mac OS X El Capitan 10.11 计算机:MacBook Pro Retina,2015 年末。(几周前的新计算机)
以下是似乎有相同问题的两种情况。
场景 1:我正在尝试编译 Android 源代码以创建自定义 ROM。我已经按照OS X的http://source.android.com上的步骤进行操作,特别是关于 MAC 部分的http://source.android.com/source/initializing.html。
我已经运行了所有步骤,直到构建系统。下一步是
source build/envsetup.sh
lunch aosp_eng
弹出此错误@午餐 aosp_eng:
*** Error: could not find jdk tools.jar at /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/../lib/tools.jar, please check if your JDK was installed correctly. Stop.
** Don't have a product spec for: 'aosp_arm'
** Do you have the right repo manifest?
场景二:下载Android Studio制作app,却弹出这个错误,
'tools.jar' seems to be not in Studio classpath.
Please ensure JAVA_HOME points to JDK rather than JRE.
这是我的 .bash_profile:
export PATH=/usr/local/opt/mongodb/bin/:$PATH
# mount the android file image
function mountAndroid {
hdiutil attach ~/android.dmg.sparseimage -mountpoint /Volumes/android;
}
#unmount the android file image
function umountAndroid(){
hdiutil detach /Volumes/android;
}
export USE_CCACHE=1
#export JAVA_HOME="$(/usr/libexec/java_home)"
export JAVA_HOME="$(/usr/libexec/java_home -v 1.7)"
#export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/"
#export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home/"
#export JAVA_HOME=$(/usr/libexec/java_home)
第一行用于 Mongodb,“mounts”来自 source.android.com 的逐步过程。使用 android 教程中的 ccache 和使用 MacPorts 能够使用 ccache。所有被注释掉的JAVA_HOME都是我在网上找的解决办法。
目前,我安装了几个不同的 java 版本
jdk1.7.0_71.jdk
jdk1.7.0_79.jdk
jdk1.8.0_65.jdk
jdk1.9.0jdk
JDK 1.9 是 beta 版本,但我需要它来安装 Netbeans Dev JDK 1.9 版本,因为带有 Netbeans 1.8 的 MacBook Pro Retina 目前存在一个已知错误。滚动很慢,目前唯一的修复是 Beta 版 JDK。
根据我使用的 $JAVA_HOME ,输出:
me-mbp:~ Me$ echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home/
me-mbp:~ Me$ javac -version
java 1.8.0_65
me-mbp:~ Me$ which java
/usr/bin/java
如果我注释掉所有的$JAVA_HOME,它默认为jdk1.9。不知道为什么,但确实如此。
当我将 tools.jar 复制到 Android Studio App 文件夹(见下文)时,任何类似的解决方案都出现了。它让我“安装”Android Studio 并运行,但是当我尝试制作一个新应用程序时,它就坐在那里,什么也没做。此外,Studio 出现错误提示:使用 jdk1.9,需要更改设置(释义)。
cp /Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/lib/tools.jar /Volumes/Macintosh\ HD/Applications/Android\ Studio.app/Contents/lib/
这个问题的解决方案将是天赐之物。我的大部分工作都依赖于此,我希望能够从我的新笔记本电脑上实现。目前,我不得不远程进入一台 Ubuntu 机器来完成我所有的 Android 源代码工作。Android Studio 问题只是问题的延伸(我认为)。提前致谢。