I can't get Appium to work with latest Native Android

Hi. I’m trying to assess tools for automated mobile app testing where I work. The top contenders are Appium and Calabash. I’ve been assigned to test native Android apps with Appium.

I’m running Android Studio 2.1.1, which is using Oracle JRE 1.8.0_92-b14 x86_64 on Mac OS X El Capitan 10.11.5.

I installed the latest Android API (6.0 API Level 23). My AVD is a Nexus 5.

Android Studio is using JDK 1.8.0_60 to build my simple POC project.

I installed v1.5.2 of the Appium app for Mac. I chose the highest platform version that the Appium app would allow me to choose (Android 5.1 Lollipop API Level 22) and started the Appium server.

Whenever I try to run a simple JUnit 4.12 test, I receive the following error:
/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/bin/java -ea -Didea.launcher.port=7532 “-Didea.launcher.bin.path=/Applications/Android Studio.app/Contents/bin” -Didea.junit.sm_runner -Dfile.encoding=UTF-8 -classpath “/Applications/Android Studio.app/Contents/lib/idea_rt.jar:/Applications/Android Studio.app/Contents/plugins/junit/lib/junit-rt.jar:/Users/chris/Library/Android/sdk/platforms/android-23/data/res:/Users/chris/AndroidStudioProjects/AppiumExample/app/build/intermediates/classes/test/debug:/Users/chris/AndroidStudioProjects/AppiumExample/app/build/intermediates/classes/debug:/Users/chris/.gradle/caches/modules-2/files-2.1/com.google.oauth-client/google-oauth-client/1.18.0-rc/30281a66559f60a491748974ac17cec3483b873/google-oauth-client-1.18.0-rc.jar:/Users/chris/.gradle/caches/modules-2/files-2.1/io.netty/netty/3.5.7.Final/811465e6dfc89d7c78d21de6a9747b6046cb5403/netty-3.5.7.Final.jar:/Users/chris/Library/Android/sdk/extras/android/m2repository/com/android/support/support-annotations/23.4.0/support-annotations-23.4.0.jar:/Applications/Android Studio.app/Contents/gradle/m2repository/commons-io/commons-io/2.4/commons-io-2.4.jar:/Users/chris/.gradle/caches/modules-2/files-2.1/commons-beanutils/commons-beanutils/1.9.2/7a87d845ad3a155297e8f67d9008f4c1e5656b71/commons-beanutils-1.9.2.jar:/Users/chris/.gradle/caches/modules-2/files-2.1/com.google.code.gson/gson/2.6.2/f1bc476cc167b18e66c297df599b2377131a8947/gson-2.6.2.jar:/Users/chris/.gradle/caches/modules-2/files-2.1/org.apache.ant/ant-launcher/1.9.4/334b62cb4be0432769679e8b94e83f8fd5ed395c/ant-launcher-1.9.4.jar:/Users/chris/.gradle/caches/modules-2/files-2.1/cglib/cglib/3.2.1/e5358fe643ab732ca07b2c0a7bbdd47719cca166/cglib-3.2.1.jar:/Users/chris/.gradle/caches/modules-2/files-2.1/org.apache.commons/commons-exec/1.3/8dfb9facd0830a27b1b5f29f84593f0aeee7773b/commons-exec-1.3.jar:/Users/chris/.gradle/caches/modules-2/files-2.1/net.sf.ezmorph/ezmorph/1.0.6/1e55d2a0253ea37745d33062852fd2c90027432/ezmorph-1.0.6.jar:/Users/chris/.gradle/caches/modules-2/files-2.1/org.apache.ant/ant/1.9.4/6d473e8653d952045f550f4ef225a9591b79094a/ant-1.9.4.jar:/Users/chris/.gradle/caches/modules-2/files-2.1/org.seleniumhq.selenium/selenium-ie-driver/2.53.0/27b703e9fba9c0f636109cf4bd697c1f208ac825/selenium-ie-driver-2.53.0.jar:/Users/chris/.gradle/caches/modules-2/files-2.1/cglib/cglib-nodep/2.1_3/58d3be5953547c0019e5704d6ed4ffda3b0c7c66/cglib-nodep-2.1_3.jar:/Applications/Android Studio.app/Contents/gradle/m2repository/org/ow2/asm/asm/5.0.3/asm-5.0.3.jar:/Users/chris/.gradle/caches/modules-2/files-2.1/org.seleniumhq.selenium/selenium-firefox-driver/2.53.0/5dc655b1999898d2fc3791c649b7355d98629a69/selenium-firefox-driver-2.53.0.jar:/Users/chris/AndroidStudioProjects/AppiumExample/app/build/intermediates/exploded-aar/com.android.support/animated-vector-drawable/23.4.0/jars/classes.jar:/Users/chris/AndroidStudioProjects/AppiumExample/app/build/intermediates/exploded-aar/com.android.support/animated-vector-drawable/23.4.0/res:/Users/chris/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-annotations/2.6.0/a0990e2e812ac6639b6ce955c91b13228500476e/jackson-annotations-2.6.0.jar:/Users/chris/.gradle/caches/modules-2/files-2.1/com.google.code.findbugs/jsr305/1.3.9/40719ea6961c0cb6afaeb6a921eaa1f6afd4cfdf/jsr305-1.3.9.jar:/Users/chris/.gradle/caches/modules-2/files-2.1/org.apache.commons/commons-lang3/3.4/5fe28b9518e58819180a43a850fbc0dd24b7c050/commons-lang3-3.4.jar:/Users/chris/.gradle/caches/modules-2/files-2.1/org.seleniumhq.selenium/selenium-leg-rc/2.53.0/bdabcf672449c588913ae32973dd8f7d54f510de/selenium-leg-rc-2.53.0.jar:/Users/chris/AndroidStudioProjects/AppiumExample/app/build/intermediates/exploded-aar/com.android.support/support-v4/23.4.0/jars/classes.jar:/Users/chris/AndroidStudioProjects/AppiumExample/app/build/intermediates/exploded-aar/com.android.support/support-v4/23.4.0/res:/Users/chris/AndroidStudioProjects/AppiumExample/app/build/intermediates/exploded-aar/com.android.support/support-v4/23.4.0/jars/libs/internal_impl-23.4.0.jar:/Users/chris/.gradle/caches/modules-2/files-2.1/com.testdroid/testdroid-api/2.9/1dc64817de37ec5f063bb8b92572b013b6021c86/testdroid-api-2.9.jar:/Users/chris/.gradle/caches/modules-2/files-2.1/net.java.dev.jna/jna/4.1.0/1c12d070e602efd8021891cdd7fd18bc129372d4/jna-4.1.0.jar:/Users/chris/AndroidStudioProjects/AppiumExample/app/build/intermediates/exploded-aar/com.android.support/support-vector-drawable/23.4.0/jars/classes.jar:/Users/chris/AndroidStudioProjects/AppiumExample/app/build/intermediates/exploded-aar/com.android.support/support-vector-drawable/23.4.0/res:/Users/chris/AndroidStudioProjects/AppiumExample/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.4.0/res:/Users/chris/AndroidStudioProjects/AppiumExample/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.4.0/jars/classes.jar:/Users/chris/.gradle/caches/modules-2/files-2.1/commons-codec/commons-codec/1.9/9ce04e34240f674bc72680f8b843b1457383161a/commons-codec-1.9.jar:/Users/chris/.gradle/caches/modules-2/files-2.1/com.google.api-client/google-api-client/1.18.0-rc/45b0d00b78197d8a3047751443c09538117d188b/google-api-client-1.18.0-rc.jar:/Users/chris/.gradle/caches/modules-2/files-2.1/org.seleniumhq.selenium/selenium-safari-driver/2.53.0/c80224258a8b702c99f2d7b3847ce89dc1bcd2bd/selenium-safari-driver-2.53.0.jar:/Users/chris/.gradle/caches/modules-2/files-2.1/com.google.guava/guava/19.0/6ce200f6b23222af3d8abb6b6459e6c44f4bb0e9/guava-19.0.jar:/Users/chris/.gradle/caches/modules-2/files-2.1/commons-lang/commons-lang/2.6/ce1edb914c94ebc388f086c6827e8bdeec71ac2/commons-lang-2.6.jar:/Users/chris/.gradle/caches/modules-2/files-2.1/com.googlecode.json-simple/json-simple/1.1.1/c9ad4a0850ab676c5c64461a05ca524cdfff59f1/json-simple-1.1.1.jar:/Users/chris/.gradle/caches/modules-2/files-2.1/net.sf.json-lib/json-lib/2.4/136743e0d12df4e785e62b48618cee169b2ae546/json-lib-2.4-jdk15.jar:/Users/chris/.gradle/caches/modules-2/files-2.1/io.appium/java-client/4.0.0/b73316f27bb70d60081429c768cf09a09f6eeece/java-client-4.0.0.jar:/Users/chris/.gradle/caches/modules-2/files-2.1/org.seleniumhq.selenium/selenium-api/2.53.0/a6105ad5c43dcc02c1cf87250111b0a7f1a7c2e6/selenium-api-2.53.0.jar:/Users/chris/.gradle/caches/modules-2/files-2.1/commons-collections/commons-collections/3.2.2/8ad72fe39fa8c91eaaf12aadb21e0c3661fe26d5/commons-collections-3.2.2.jar:/Users/chris/.gradle/caches/modules-2/files-2.1/org.seleniumhq.selenium/selenium-remote-driver/2.53.0/eb76ed037ba5a7c11cce11effd0e2175056905ac/selenium-remote-driver-2.53.0.jar:/Users/chris/.gradle/caches/modules-2/files-2.1/javax.xml.stream/stax-api/1.0-2/d6337b0de8b25e53e81b922352fbea9f9f57ba0b/stax-api-1.0-2.jar:/Users/chris/.gradle/caches/modules-2/files-2.1/org.seleniumhq.selenium/selenium-java/2.53.0/645a24b52c9e5704e900ac755b5800352e981af7/selenium-java-2.53.0.jar:/Users/chris/.gradle/caches/modules-2/files-2.1/org.hamcrest/hamcrest-core/1.3/42a25dc3219429f0e5d060061f71acb49bf010a0/hamcrest-core-1.3.jar:/Users/chris/.gradle/caches/modules-2/files-2.1/com.google.http-client/google-http-client/1.18.0-rc/880ad30d2b249a7591c195c2392646f1b146c139/google-http-client-1.18.0-rc.jar:/Users/chris/.gradle/caches/modules-2/files-2.1/commons-validator/commons-validator/1.5.0/26b98c21975c5caf6bf34bacdeb7183be7a65970/commons-validator-1.5.0.jar:/Users/chris/.gradle/caches/modules-2/files-2.1/junit/junit/4.12/2973d150c0dc1fefe998f834810d68f278ea58ec/junit-4.12.jar:/Users/chris/.gradle/caches/modules-2/files-2.1/org.seleniumhq.selenium/selenium-chrome-driver/2.53.0/7541a3948c3fb31122ee9633731e8103f3292b0a/selenium-chrome-driver-2.53.0.jar:/Users/chris/.gradle/caches/modules-2/files-2.1/net.java.dev.jna/jna-platform/4.1.0/23457ad1cf75c2c16763330de5565a0e67b4bc0a/jna-platform-4.1.0.jar:/Users/chris/.gradle/caches/modules-2/files-2.1/org.seleniumhq.selenium/selenium-edge-driver/2.53.0/9f3da0dfa620ae8cd71afacfdd6ddae5028ce1ea/selenium-edge-driver-2.53.0.jar:/Users/chris/.gradle/caches/modules-2/files-2.1/commons-digester/commons-digester/1.8.1/3dec9b9c7ea9342d4dbe8c38560080d85b44a015/commons-digester-1.8.1.jar:/Users/chris/.gradle/caches/modules-2/files-2.1/org.seleniumhq.selenium/selenium-support/2.53.0/3706aa8a696d1b7938365a41ee7ca46309a0b2d/selenium-support-2.53.0.jar:/Users/chris/AndroidStudioProjects/AppiumExample/app/build/intermediates/sourceFolderJavaResources/test/debug:/Users/chris/AndroidStudioProjects/AppiumExample/app/build/intermediates/sourceFolderJavaResources/debug:/Users/chris/AndroidStudioProjects/AppiumExample/build/generated/mockable-android-23.jar” com.intellij.rt.execution.application.AppMain com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 commercial.baxter.com.appiumexample.BaseTest

java.lang.NoClassDefFoundError: org/apache/http/auth/Credentials

at io.appium.java_client.remote.AppiumCommandExecutor.<init>(AppiumCommandExecutor.java:55)
at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:131)
at io.appium.java_client.android.AndroidDriver.<init>(AndroidDriver.java:97)
at commercial.baxter.com.appiumexample.BaseTest.setUp(BaseTest.java:29)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)

Caused by: java.lang.ClassNotFoundException: org.apache.http.auth.Credentials
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
… 31 more

java.lang.NullPointerException
at commercial.baxter.com.appiumexample.BaseTest.tearDown(BaseTest.java:45)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:33)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)

Process finished with exit code 255

Here is my Gradle build file:
apply plugin: ‘com.android.application’

android {
compileSdkVersion 23
buildToolsVersion “23.0.3”

defaultConfig {
    applicationId "commercial.baxter.com.appiumexample"
    minSdkVersion 15
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

}

dependencies {
compile fileTree(dir: ‘libs’, include: [’*.jar’])
testCompile ‘junit:junit:4.12’

compile 'com.android.support:appcompat-v7:23.4.0'

compile 'io.appium:java-client:4.0.0'
compile ('com.googlecode.json-simple:json-simple:1.1.1') {
    exclude group: 'junit'
}
compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
compile 'commons-lang:commons-lang:2.6'
compile 'com.google.code.gson:gson:2.6.2'
compile 'com.google.http-client:google-http-client:1.22.0'
compile 'com.testdroid:testdroid-api:2.9'
compile 'com.google.http-client:google-http-client-jackson2:1.22.0'

}

Here’s my test class:
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.remote.DesiredCapabilities;

import java.net.URL;

import io.appium.java_client.AppiumDriver;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.remote.MobileCapabilityType;

/**

  • Created by chris on 5/31/16.
    */
    public class BaseTest {
    private AppiumDriver driver;

    @Before
    public void setUp() throws Exception {
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, “Android”);
    capabilities.setCapability(MobileCapabilityType.DEVICE_NAME,“AndroidTestDevice”);
    capabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, 4000);
    driver = new AndroidDriver(new URL(“http://127.0.0.1:4723/wd/hub”), capabilities);

    }

    @Test
    public void clickButton(){
    driver.findElementById(“exampleButton”).click();
    Assert.assertTrue(driver.findElementById(“exampleMessage”).isDisplayed());

    }

    @After
    public void tearDown() throws Exception {
    driver.quit();
    }
    }

Whenever I build the project, I see the following output:
Executing tasks: [:app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies]

Configuration on demand is an incubating feature.
WARNING: Dependency org.apache.httpcomponents:httpclient:4.5.2 is ignored for debug as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
WARNING: Dependency org.apache.httpcomponents:httpclient:4.5.2 is ignored for debug as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
WARNING: Dependency commons-logging:commons-logging:1.2 is ignored for debug as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
WARNING: Dependency commons-logging:commons-logging:1.2 is ignored for debug as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
WARNING: Dependency org.apache.httpcomponents:httpclient:4.5.2 is ignored for debug as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
WARNING: Dependency commons-logging:commons-logging:1.2 is ignored for debug as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
WARNING: Dependency org.apache.httpcomponents:httpclient:4.5.2 is ignored for debug as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
WARNING: Dependency org.apache.httpcomponents:httpclient:4.5.2 is ignored for release as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
WARNING: Dependency org.apache.httpcomponents:httpclient:4.5.2 is ignored for release as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
WARNING: Dependency commons-logging:commons-logging:1.2 is ignored for release as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
WARNING: Dependency commons-logging:commons-logging:1.2 is ignored for release as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
WARNING: Dependency org.apache.httpcomponents:httpclient:4.5.2 is ignored for release as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
WARNING: Dependency commons-logging:commons-logging:1.2 is ignored for release as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
WARNING: Dependency org.apache.httpcomponents:httpclient:4.5.2 is ignored for release as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
Incremental java compilation is an incubating feature.
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAnimatedVectorDrawable2340Library UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72340Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42340Library UP-TO-DATE
:app:prepareComAndroidSupportSupportVectorDrawable2340Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:mergeDebugShaders UP-TO-DATE
:app:compileDebugShaders UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:preDebugAndroidTestBuild UP-TO-DATE
:app:prepareDebugAndroidTestDependencies
:app:compileDebugAndroidTestAidl UP-TO-DATE
:app:processDebugAndroidTestManifest UP-TO-DATE
:app:compileDebugAndroidTestRenderscript UP-TO-DATE
:app:generateDebugAndroidTestBuildConfig UP-TO-DATE
:app:mergeDebugAndroidTestShaders UP-TO-DATE
:app:compileDebugAndroidTestShaders UP-TO-DATE
:app:generateDebugAndroidTestAssets UP-TO-DATE
:app:mergeDebugAndroidTestAssets UP-TO-DATE
:app:generateDebugAndroidTestResValues UP-TO-DATE
:app:generateDebugAndroidTestResources UP-TO-DATE
:app:mergeDebugAndroidTestResources UP-TO-DATE
:app:processDebugAndroidTestResources UP-TO-DATE
:app:generateDebugAndroidTestSources UP-TO-DATE
:app:mockableAndroidJar UP-TO-DATE
:app:preDebugUnitTestBuild UP-TO-DATE
:app:prepareDebugUnitTestDependencies

BUILD SUCCESSFUL

Total time: 0.588 secs

I read that the Apache HttpClient was removed from API Level 23, and it seems that the io.appium:java-client dependency is built on top of Apache HttpClient 4.5.2.

Is this the case and the root of my problems?
If so, what do I need to do?
If not so, what am I doing wrong?

  • Chris

It looks like you’re trying to run an Appium test as an Android project instrumented unit test.

  1. Appium, both the server and the process running the test code, should not be running on the same device where the actual testing will occur. A typical Appium setup would be to have the test code run on some host machine with an Android device connected to this host machine, and this host machine is also running the Appium server.

  2. Make sure your testing code gets executed after the APK is built in the build process. (Might be easier to create a new task in your build.gradle and have this new task execute your Appium tests. You can have the new task declare a dependency on the relevant assemble task, and have the Android plugin’s built-in check task declare a dependency on this new task).

  3. Your testing code needs to include an absolute file path to the new APK for Appium to pick it up and run its tests.

  4. Swap your your Gradle compile configuration dependencies for testCompile configuration dependencies. e.g. instead of compile 'io.appium:java-client:4.0.0', have testCompile 'io.appium:java-client:4.0.0'.

Just beware that Appium should be treated as a tool to help with black-box, high-level UI tests. If you’re trying to use Appium to test something like determining if a ListView’s adapter backing data has a certain number of elements, you’re likely to run into difficulty (use an Android instrumented test or a regular local JVM unit test for things like that).

Thanks, @afwang.

The ultimate goal is to integrate Appium with Jenkins. The intended result is for Jenkins to scan SVN for code commits, begin the build, run unit tests, and then finally run the Appium tests.

Addressing your first point, let’s see if I have this right…

So, the host machine would be the physical server on which Jenkins and the Appium server are running, but I would need a physical device, plugged into the server, on which to actually run the test code?

My hope was to use an emulator instead of a physical device. Relying on physical devices plugged into the server will probably defeat the purposes of my efforts.

The rest of your points make sense to me, though I may have some further questions sorting out which dependencies need to be classified as “testCompile” vs “compile”.

Yes, you can run an emulator. I have been able to automate with an emulator, but my experience with them has been abysmal, so I usually recommend real devices.

You can also take a look at some service/cloud-based solutions, where the emulators and Appium management is handled for you.