Android Studio 启动 Device Monitor报错:An error has occurred. See the log file...

报错信息

D:\xxx\sdk是我的sdk路径,于是到此目录下查看日志文件,描述如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
!ENTRY org.eclipse.osgi 4 0 2016-08-04 11:21:12.845
!MESSAGE Application error
!STACK 1
java.io.IOException: The folder "C:\Users\Lison%20Liou\.android\monitor-workspace\.metadata" is read-only.
at org.eclipse.core.runtime.internal.adaptor.BasicLocation.lock(BasicLocation.java:206)
at org.eclipse.core.runtime.internal.adaptor.BasicLocation.set(BasicLocation.java:164)
at org.eclipse.core.runtime.internal.adaptor.BasicLocation.set(BasicLocation.java:137)
at com.android.ide.eclipse.monitor.MonitorApplication.start(MonitorApplication.java:53)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:353)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:629)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)
at org.eclipse.equinox.launcher.Main.run(Main.java:1438)

错误信息说目录是只读的,但目录只有C:/Users/Lison Liou/.android,后面就没有了,于是干脆给目录加上Everyone用户的Full Control权限,结果还是不行。

后来在StackOverFlow上找到答案,Android DDMS (Monitor) does not start if user profile contains a space in it,说DDMS不会启动如果用户名包含空格,我的用户名的确包含空格,但是之前也是好用的,不解。

解决方法如下:以管理员身份运行cmd(必须),输入如下:

1
2
3
cd c:/users

mklink /d "Lison%20Liou" "Lison Liou"

将带空格的用户与正常用户名建立链接(软连接或者硬链接就不知道了),Lison Liou是我的计算机用户,成功后会提示:

symbolic link created for Lison%20Liou <<===>> Lison Liou

搞定。