AppiumDriver<MobileElement> driver = new AndroidDriver<MobileElement>(caps);
I have added java-client06.0.0-BETA2.jar to my build path.
When I try to run, I get this error: Exception in thread “main” java.lang.NoClassDefFoundError: com/google/common/base/Function
at tests.AppiumTest.main(AppiumTest.java:27)
Caused by: java.lang.ClassNotFoundException: com.google.common.base.Function
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)
I looked it up and it appears that there are some dependencies missing in the classpath. The link leads to github issue that pertains to Selenium, but since Appium is based on Selenium, I think it would be relevant in your case. Basically it says that “Selenium requires guava library to be in classpath.”.
To avoid dependency issues, I prefer to work with Gradle. I assume that you are working with Eclipse since the tutorial you linked to makes use of Eclipse.
In Eclipse → File → New → Project → Gradle Project. Name your project and click finish. Eclipse will initialize Gradle project for you.
Then open the file titled build.gradle and paste the following code into the file:
Then right click on the project in the project explorer → Gradle → Refersh Gradle Project. That should fetch all the dependencies and allow you to execute your tests.
Thank you @Nivi_Mor. Your solution worked. I tried first the android version of Guava - that gave a completely different error, but when I added the regular version, everything worked & my app was launched on the device: