Failed to Launch Android Device Monitor

Every time I reformatted my machine and reinstall back Android Studio / Visual Studio. There are always some components in Android development tools are broken. It work perfectly previous, but now it doesn’t work on new freshly installed machine. It is always a new problem. This is annoying.

When I launch Android Device Monitor from Visual Studio 2017 or launch the android device monitor manually from executable. The following error pop up.

Failed to load the JNI shared library “C:\Program Files\Java\jdk1.8.0_181\bin\..\jre\bin\server\jvm.dll”

Depend on your installed JDK version, the error message might be different.

This is because Visual Studio tried to launch the x86 version of Android Device Monitor, while my machine only have x64 Java SDK / JDK installed, so it complain that. Unlike previous Visual Studio which install x86 JDK, all new Visual Studio now come with x64 JDK only.

Solution: Instead of launching the Android Device Monitor from Visual Studio, launch the x64 version of Android Device Monitor manually from the following path.

C:\Program Files (x86)\Android\android-sdk\tools\lib\monitor-x86_64\monitor.exe

Ops, another new error popup instead. Now it show the following error instead.

A Java Runtime Environment (JRE) or Java Development JDK (JDK) must be available in order to run Monitor. No Java virtual machine was found after searching the following locations:

C:\Programs Files (x86)\Android\android-sdk\tools\monitor-x86_64\jre\bin\javaw.exe javaw.exe in your current PATH.

It seem like the new Android SDK is screw up or something. This will also happen if you have a x86 JDK and launch the x86 Android Device Monitor. I have no idea about the root cause, but I have a quick solution for that. Create a link folder in the missing path to link it the Java SDK in your machine. No, please don’t copy the whole JDK to that folder. Gosh.

Launch a command prompt with administrator right (Search command prompt in start menu then Shift+Ctrl+Enter will launch command prompt with administrator right), and enter the magic command.

mklink /j “C:\Program Files (x86)\Android\android-sdk\tools\lib\monitor-x86_64\jre” “C:\Program Files\Java\jdk1.8.0_181\jre”

This created a junction folder to link the folder together.

Hopefully your Android Device Monitor launch without problem now. Eh, wait, another problem.

An error has occurred. See the log file C:\User\{username}\.eclipse\org.eclipse.platform bla bla bla bla bla

Find the log file and it shown. The folder “C:\Users\{username}\.android\monitor-workspace\.metadata” is read-only.

This make no sense as I don’t have this file or path at all. Ok, if your username in Windows have space in between like mine, you got the same problem. Lets just do the same trick by creating another link folder using command prompt.

mklink /j “C:\Users\User%20Name%20With%20Space” “C:\Users\User Name With Space”

Please replace the user name with your user name in Windows and also replace the space in the link folder with %20 instead. If the user folder already exist, check the folder. It is most likely created by Visual Studio to put some log file inside, which is safe to delete it.

Ok, now launch the Android Device Monitor and pray it work.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s