Instrumentation Failed: Android hybrid app

Hi,

I’ve been working on this for a few days now and it’s bugging me quite a bit.
I’m working on debian and trying to get appium to work with a phonegap app.
This is my setup:

  • Android lolipop 5.1.1 (OnePlus One phone)
  • Appium v1.4.16

I’m trying to get this tutorial work: https://github.com/ezodude/appium-smoke-tester.
These are my capabilities:
exports.android = {
browserName: ‘’,
platformName: ‘Android’,
platformVersion: ‘5.1.1’,
deviceName: ‘OnePlus’,
automationName: ‘selendroid’,
};
And this is my appium log:
info: Welcome to Appium v1.4.16 (REV ae6877eff263066b26328d457bd285c0cc62430d)
info: Appium REST http interface listener started on 0.0.0.0:4723
info: Console LogLevel: debug
info: --> POST /wd/hub/session {“desiredCapabilities”:{“browserName”:"",“platformName”:“Android”,“platformVersion”:“5.1.1”,“deviceName”:“OnePlus”,“automationName”:“selendroid”,“app”:"…/…/sample-code/apps/android/BeanThere-debug.apk",“appPackage”:“com.domain.appname”,“appActivity”:".ActivityName"}}
info: Client User-Agent string: admc/wd/0.3.12
info: [debug] Using local app from desired caps: /home/patate/test/appium-smoke-tester/sample-code/apps/android/BeanThere-debug.apk
info: [debug] Creating new appium session bd6b3359-79ab-4bb9-8d78-a8a356612c8d
info: [debug] Starting selendroid server
info: [debug] Getting Java version
info: Java version is: 1.7.0_91
info: [debug] Checking whether adb is present
info: [debug] Using adb from /home/patate/android-sdk-linux/platform-tools/adb
info: [debug] Checking whether selendroid is built yet
info: [debug] Selendroid server exists!
info: [debug] Using fast reset? true
info: [debug] Preparing device for session
info: [debug] Checking whether app is actually present
info: Retrieving device
info: [debug] Trying to find a connected android device
info: [debug] Getting connected devices…
info: [debug] executing cmd: /home/patate/android-sdk-linux/platform-tools/adb devices
info: [debug] 1 device(s) connected
info: Found device [device] info: [debug] Setting device id to [device] info: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5)
info: [debug] executing cmd: /home/patate/android-sdk-linux/platform-tools/adb -s [device] wait-for-device
info: [debug] executing cmd: /home/patate/android-sdk-linux/platform-tools/adb -s [device] shell “echo ‘ready’”
info: [debug] Starting logcat capture
info: [debug] Checking whether aapt is present
info: [debug] Using aapt from /home/patate/android-sdk-linux/build-tools/23.0.2/aapt
info: [debug] Checking if has internet permission from manifest.
info: [debug] executing cmd: /home/patate/android-sdk-linux/build-tools/23.0.2/aapt dump badging /home/patate/test/appium-smoke-tester/sample-code/apps/android/BeanThere-debug.apk
info: [debug] Rebuilt selendroid server does not exist, inserting modified manifest
info: [debug] Inserting selendroid manifest
info: [debug] Checking whether aapt is present
info: [debug] Using aapt from /home/patate/android-sdk-linux/build-tools/23.0.2/aapt
info: [debug] Compiling manifest /tmp/com.domain.appname/AndroidManifest.xml
info: [debug] Compiling manifest.
info: [debug] executing cmd: /home/patate/android-sdk-linux/build-tools/23.0.2/aapt package -M /tmp/com.domain.appname/AndroidManifest.xml --rename-manifest-package com.domain.appname.selendroid --rename-instrumentation-target-package com.domain.appname -I /home/patate/android-sdk-linux/platforms/android-21/android.jar -F /tmp/com.domain.appname/AndroidManifest.xml.apk -f
info: [debug] Compiled manifest
info: [debug] Inserting manifest, src: /home/patate/test/appium-smoke-tester/node_modules/appium/build/selendroid/selendroid.apk, dst: /tmp/selendroid.com.domain.appname.apk
info: [debug] Extracting manifest
info: [debug] Unzipping /tmp/com.domain.appname/AndroidManifest.xml.apk
info: [debug] Testing zip archive: /tmp/com.domain.appname/AndroidManifest.xml.apk
info: [debug] Zip archive tested clean
info: [debug] Unzip successful
info: [debug] Writing tmp apk. /home/patate/test/appium-smoke-tester/node_modules/appium/build/selendroid/selendroid.apk to /tmp/selendroid.com.domain.appname.apk
info: [debug] Testing new tmp apk.
info: [debug] Testing zip archive: /tmp/selendroid.com.domain.appname.apk
info: [debug] Zip archive tested clean
info: [debug] Moving manifest.
info: [debug] executing cmd: zip -j -m /tmp/selendroid.com.domain.appname.apk /tmp/com.domain.appname/AndroidManifest.xml
info: [debug] Inserted manifest.
info: [debug] Checking signed status of /tmp/selendroid.com.domain.appname.apk
info: [debug] Checking app cert for /tmp/selendroid.com.domain.appname.apk.
info: [debug] executing cmd: java -jar /home/patate/test/appium-smoke-tester/node_modules/appium/node_modules/appium-adb/jars/verify.jar /tmp/selendroid.com.domain.appname.apk
info: [debug] Checking signed status of /home/patate/test/appium-smoke-tester/sample-code/apps/android/BeanThere-debug.apk
info: [debug] Checking app cert for /home/patate/test/appium-smoke-tester/sample-code/apps/android/BeanThere-debug.apk.
info: [debug] executing cmd: java -jar /home/patate/test/appium-smoke-tester/node_modules/appium/node_modules/appium-adb/jars/verify.jar /home/patate/test/appium-smoke-tester/sample-code/apps/android/BeanThere-debug.apk
info: [debug] App not signed with debug cert.
info: [debug] Resigning apk.
info: [debug] executing cmd: java -jar /home/patate/test/appium-smoke-tester/node_modules/appium/node_modules/appium-adb/jars/sign.jar /tmp/selendroid.com.domain.appname.apk --override
info: [debug] App already signed.
info: [debug] Zip-aligning /home/patate/test/appium-smoke-tester/sample-code/apps/android/BeanThere-debug.apk
info: [debug] Checking whether zipalign is present
info: [debug] Using zipalign from /home/patate/android-sdk-linux/build-tools/23.0.2/zipalign
info: [debug] Zip-aligning apk.
info: [debug] executing cmd: /home/patate/android-sdk-linux/build-tools/23.0.2/zipalign -f 4 /home/patate/test/appium-smoke-tester/sample-code/apps/android/BeanThere-debug.apk /tmp/11608-11910-ecmond/appium.tmp
info: [debug] Zip-aligning /tmp/selendroid.com.domain.appname.apk
info: [debug] Checking whether zipalign is present
info: [debug] Using zipalign from /home/patate/android-sdk-linux/build-tools/23.0.2/zipalign
info: [debug] Zip-aligning apk.
info: [debug] executing cmd: /home/patate/android-sdk-linux/build-tools/23.0.2/zipalign -f 4 /tmp/selendroid.com.domain.appname.apk /tmp/11608-11910-1ln27ik/appium.tmp
info: [debug] Rebuilt selendroid apk does not exist, uninstalling any instances of it on device to make way for new one
info: [debug] Uninstalling com.domain.appname.selendroid
info: [debug] executing cmd: /home/patate/android-sdk-linux/platform-tools/adb -s [device] shell “am force-stop com.domain.appname.selendroid”
info: [debug] executing cmd: /home/patate/android-sdk-linux/platform-tools/adb -s [device] uninstall com.domain.appname.selendroid
info: [debug] App was not uninstalled, maybe it wasn’t on device?
info: [debug] Getting install status for com.domain.appname.selendroid
info: [debug] Getting device API level
info: [debug] executing cmd: /home/patate/android-sdk-linux/platform-tools/adb -s [device] shell “getprop ro.build.version.sdk”
info: [debug] Device is at API Level 22
info: [debug] executing cmd: /home/patate/android-sdk-linux/platform-tools/adb -s [device] shell “pm list packages -3 com.domain.appname.selendroid”
info: [debug] App is not installed
info: [debug] Rebuilt selendroid is not installed, installing it
info: [debug] executing cmd: /home/patate/android-sdk-linux/platform-tools/adb -s [device] install -r “/tmp/selendroid.com.domain.appname.apk”
info: [debug] Extracting strings for language: default
info: [debug] executing cmd: /home/patate/android-sdk-linux/platform-tools/adb -s [device] shell “getprop persist.sys.language”
info: [debug] Current device persist.sys.language: fr
info: [debug] java -jar “/home/patate/test/appium-smoke-tester/node_modules/appium/node_modules/appium-adb/jars/appium_apk_tools.jar” “stringsFromApk” “/home/patate/test/appium-smoke-tester/sample-code/apps/android/BeanThere-debug.apk” “/tmp/com.domain.appname” fr
info: [debug] No strings.xml for language ‘fr’, getting default strings.xml
info: [debug] java -jar “/home/patate/test/appium-smoke-tester/node_modules/appium/node_modules/appium-adb/jars/appium_apk_tools.jar” “stringsFromApk” “/home/patate/test/appium-smoke-tester/sample-code/apps/android/BeanThere-debug.apk” “/tmp/com.domain.appname”
info: [debug] Reading strings from converted strings.json
info: [debug] Setting language to default
info: [debug] Not uninstalling app since server not started with --full-reset
info: [debug] Checking app cert for /home/patate/test/appium-smoke-tester/sample-code/apps/android/BeanThere-debug.apk.
info: [debug] executing cmd: java -jar /home/patate/test/appium-smoke-tester/node_modules/appium/node_modules/appium-adb/jars/verify.jar /home/patate/test/appium-smoke-tester/sample-code/apps/android/BeanThere-debug.apk
info: [debug] App already signed.
info: [debug] Zip-aligning /home/patate/test/appium-smoke-tester/sample-code/apps/android/BeanThere-debug.apk
info: [debug] Checking whether zipalign is present
info: [debug] Using zipalign from /home/patate/android-sdk-linux/build-tools/23.0.2/zipalign
info: [debug] Zip-aligning apk.
info: [debug] executing cmd: /home/patate/android-sdk-linux/build-tools/23.0.2/zipalign -f 4 /home/patate/test/appium-smoke-tester/sample-code/apps/android/BeanThere-debug.apk /tmp/11608-11910-dbsm4y/appium.tmp
info: [debug] MD5 for app is e44c32ebcb3a5d684dcac4a334e4e754
info: [debug] executing cmd: /home/patate/android-sdk-linux/platform-tools/adb -s [device] shell “ls /data/local/tmp/e44c32ebcb3a5d684dcac4a334e4e754.apk”
info: [debug] Getting install status for com.domain.appname
info: [debug] Getting device API level
info: [debug] executing cmd: /home/patate/android-sdk-linux/platform-tools/adb -s [device] shell “getprop ro.build.version.sdk”
info: [debug] Device is at API Level 22
info: [debug] executing cmd: /home/patate/android-sdk-linux/platform-tools/adb -s [device] shell “pm list packages -3 com.domain.appname”
info: [debug] App is not installed
info: Installing App
info: [debug] executing cmd: /home/patate/android-sdk-linux/platform-tools/adb -s [device] shell “mkdir -p /data/local/tmp/”
info: [debug] Removing any old apks
info: [debug] executing cmd: /home/patate/android-sdk-linux/platform-tools/adb -s [device] shell “ls /data/local/tmp/*.apk”
info: [debug] Found an apk we want to keep at /data/local/tmp/e44c32ebcb3a5d684dcac4a334e4e754.apk
info: [debug] Couldn’t find any apks to remove
info: [debug] Uninstalling com.domain.appname
info: [debug] executing cmd: /home/patate/android-sdk-linux/platform-tools/adb -s [device] shell “am force-stop com.domain.appname”
info: [debug] executing cmd: /home/patate/android-sdk-linux/platform-tools/adb -s [device] uninstall com.domain.appname
info: [debug] App was not uninstalled, maybe it wasn’t on device?
info: [debug] executing cmd: /home/patate/android-sdk-linux/platform-tools/adb -s [device] shell “pm install -r /data/local/tmp/e44c32ebcb3a5d684dcac4a334e4e754.apk”
info: [debug] Forwarding system:8080 to device:8080
info: [debug] executing cmd: /home/patate/android-sdk-linux/platform-tools/adb -s [device] forward tcp:8080 tcp:8080
info: [debug] Pushing settings apk to device…
info: [debug] executing cmd: /home/patate/android-sdk-linux/platform-tools/adb -s [device] install “/home/patate/test/appium-smoke-tester/node_modules/appium/build/settings_apk/settings_apk-debug.apk”
info: [debug] Pushing unlock helper app to device…
info: [debug] executing cmd: /home/patate/android-sdk-linux/platform-tools/adb -s [device] install “/home/patate/test/appium-smoke-tester/node_modules/appium/build/unlock_apk/unlock_apk-debug.apk”
info: [debug] executing cmd: /home/patate/android-sdk-linux/platform-tools/adb -s [device] shell “dumpsys window”
info: Unlocking screen
info: [debug] Screen is locked, trying to unlock
info: [debug] Getting device API level
info: [debug] executing cmd: /home/patate/android-sdk-linux/platform-tools/adb -s [device] shell “getprop ro.build.version.sdk”
info: [debug] Device is at API Level 22
info: [debug] executing cmd: /home/patate/android-sdk-linux/platform-tools/adb -s [device] shell “am start -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000 -n io.appium.unlock/.Unlock”
info: [debug] executing cmd: /home/patate/android-sdk-linux/platform-tools/adb -s [device] shell “dumpsys window”
info: [debug] Screen is locked, trying to unlock
info: [debug] Getting device API level
info: [debug] executing cmd: /home/patate/android-sdk-linux/platform-tools/adb -s [device] shell “getprop ro.build.version.sdk”
info: [debug] Device is at API Level 22
info: [debug] executing cmd: /home/patate/android-sdk-linux/platform-tools/adb -s [device] shell “am start -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000 -n io.appium.unlock/.Unlock”
info: [debug] executing cmd: /home/patate/android-sdk-linux/platform-tools/adb -s [device] shell “dumpsys window”
info: [debug] Screen is locked, trying to unlock
info: [debug] Getting device API level
info: [debug] executing cmd: /home/patate/android-sdk-linux/platform-tools/adb -s [device] shell “getprop ro.build.version.sdk”
info: [debug] Device is at API Level 22
info: [debug] executing cmd: /home/patate/android-sdk-linux/platform-tools/adb -s [device] shell “am start -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000 -n io.appium.unlock/.Unlock”
info: [debug] executing cmd: /home/patate/android-sdk-linux/platform-tools/adb -s [device] shell “dumpsys window”
info: [debug] Screen is unlocked, continuing
info: [debug] executing cmd: /home/patate/android-sdk-linux/platform-tools/adb -s [device] shell “am instrument -e main_activity ‘com.domain.appname.ActivityName’ com.domain.appname.selendroid/io.selendroid.server.ServerInstrumentation”
error: android.util.AndroidException: INSTRUMENTATION_FAILED: com.domain.appname.selendroid/io.selendroid.server.ServerInstrumentation
at com.android.commands.am.Am.runInstrument(Am.java:977)
at com.android.commands.am.Am.onRun(Am.java:317)
at com.android.internal.os.BaseCommand.run(BaseCommand.java:47)
at com.android.commands.am.Am.main(Am.java:97)
at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:249)
info: [debug] Cleaning up appium session
error: Failed to start an Appium session, err was: Error: android.util.AndroidException: INSTRUMENTATION_FAILED: com.domain.appname.selendroid/io.selendroid.server.ServerInstrumentation
info: [debug] Error: android.util.AndroidException: INSTRUMENTATION_FAILED: com.domain.appname.selendroid/io.selendroid.server.ServerInstrumentation
at /home/patate/test/appium-smoke-tester/node_modules/appium/node_modules/appium-adb/lib/adb.js:1394:17
at [object Object]. (/home/patate/test/appium-smoke-tester/node_modules/appium/node_modules/appium-adb/lib/adb.js:180:9)
at ChildProcess.exithandler (child_process.js:742:7)
at ChildProcess.emit (events.js:110:17)
at maybeClose (child_process.js:1016:16)
at Process.ChildProcess._handle.onexit (child_process.js:1088:5)
info: [debug] Responding to client with error: {“status”:33,“value”:{“message”:“A new session could not be created. (Original error: android.util.AndroidException: INSTRUMENTATION_FAILED: com.domain.appname.selendroid/io.selendroid.server.ServerInstrumentation\r)”,“origValue”:“android.util.AndroidException: INSTRUMENTATION_FAILED: com.domain.appname.selendroid/io.selendroid.server.ServerInstrumentation\r”},“sessionId”:null}
info: <-- POST /wd/hub/session 500 19066.200 ms - 380
info: [debug] Logcat terminated with code 0, signal null