androidsdknoclassdeffounderrormonkeyrunner

MonkeyRunner NoClassDefFoundError: com/android/chimpchat/ChimpChat


I got an exception while try to run MonkeyRunner.bat.
I found only this solution but its very old and with no success.

Console line:

mymonkeyrunner test.py

The Error:

Exception in thread "main" java.lang.NoClassDefFoundError: com/android/chimpchat/ChimpChat
        at com.android.monkeyrunner.MonkeyRunnerStarter.<init>(MonkeyRunnerStarter.java:60)
        at com.android.monkeyrunner.MonkeyRunnerStarter.main(MonkeyRunnerStarter.java:188)
Caused by: java.lang.ClassNotFoundException: com.android.chimpchat.ChimpChat
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        ... 2 more

Solution

  • Shortly after posting the comment, I figured it out. After fixing the Chimp issue, there were more libraries that Monkeyrunner was not able to find. In the end, it seemed easier to do the following:

    You probably have your $ANDROID_SWT set to something like sdk_dir\tools\lib\x86_64. Copy your ANDROID_SWT\swt.jar into sdk_dir\tools\lib and then set $ANDROID_SWT to sdk_dir\tools\lib.

    After I fixed this issue, I had problems with Monkeyrunner not finding adb. For that, I had to replace the last line in monkeyrunner.bat from

    call "%java_exe%" -Xmx512m "-Djava.ext.dirs=%frameworkdir%;%swt_path%" -Dcom.android.monkeyrunner.bindir=..\framework -jar %jarpath% %*

    to

    call "%java_exe%" -Xmx512m "-Djava.ext.dirs=%frameworkdir%;%swt_path%" -Dcom.android.monkeyrunner.bindir=..\..\platform-tools -jar %jarpath% %*

    Basically, make sure that -Dcom.android.monkeyrunner.bindir points to where adb.exe is sitting. Now it seems to be working.