这个问题的原因是我mac上的jdk版本过高导致的,需要降低jdk的版本为jdk1.8.0_144
首先查看java版本: java -version
java version "1.8.0_191"
Java(TM) SE Runtime Environment (build 1.8.0_191-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)
which java 查看java路径 :
/usr/bin/java
sudo vim /etc/profile
JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_191.jdk/Contents/Home"
export JAVA_HOME
CLASS_PATH="$JAVA_HOME/bin"
PATH=".$PATH:$JAVA_HOME/bin"
现在想把java版本降低,下载路径:
https://pan.baidu.com/s/1H6v23ioix4zfoRu3Vh10Fg
先在电脑上删除旧的jdk,步骤如下:
Run this command to just remove the JDK
sudo rm -rf /Library/Java/JavaVirtualMachines/jdk<version>.jdk
Run these commands if you want to remove plugins
sudo rm -rf /Library/PreferencePanes/JavaControlPanel.prefPane
sudo rm -rf /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
sudo rm -rf /Library/LaunchAgents/com.oracle.java.Java-Updater.plist
sudo rm -rf /Library/PrivilegedHelperTools/com.oracle.java.JavaUpdateHelper
sudo rm -rf /Library/LaunchDaemons/com.oracle.java.Helper-Tool.plist
sudo rm -rf /Library/Preferences/com.oracle.java.Helper-Tool.plist
安装新的jdk
安装好jdk之后,就开始配置环境变量了。
sudo vim /etc/profile
修改为如下
JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home"
export JAVA_HOME
CLASS_PATH="$JAVA_HOME/lib"
PATH=".$PATH:$JAVA_HOME/bin"
执行source /etc/profile
输入echo $JAVA_HOME,看到:
/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home
打开android studio,在file->project structure里面修改jdk location为上面的路径
然后打开你的/Users/username/Library/Android/sdk/tools里面的monitor.bat,就可以看到android device monitor 界面了.
但是进入之后又遇到一个新问题:
弹出could-not-open-selected-vm-debug-port-8700
解决办法:
在android device monitor中的window-》prefrence-》ddms中将base local debgger port 改成8601,
check use adbhost
确保底下的值是127.0.0.1
参考:https://stackoverflow.com/questions/4045645/eclipse-android-could-not-open-selected-vm-debug-port-8700
网友评论