Selendroid Error Failed to Find Main Activity

Hi I’m a QA Tester working in Appium and I’ve moved away from using the GUI version to instead using the command line version. I start my service up using the following :

appium --app {app name}.apk --automation-name Selendroid

This launches the service fine and displays the message that the REST interface listener is ready and working. When i go to run my test i get the error message saying that the app.MainActivity couldn’t be found.

Here is the log:

info: [debug] Waiting for pkg “com.hbo.android.app” and activity “com.hbo.androi
d.app.activity.MainActivity” to be focused
info: [debug] Getting focused package and activity
info: [debug] executing cmd: C:\Users\brian.menzies\AppData\Local\Android\sdk\pl
atform-tools\adb.exe -s 42f75402f2ce9fd3 shell “dumpsys window windows”
info: [debug] Overriding session id with “49f05887-f391-c568-026d-2738896ef100”
info: [debug] Device launched! Ready for commands
info: [debug] Setting command timeout to the default of 60 secs
info: [debug] Appium session started with sessionId 49f05887-f391-c568-026d-2738
896ef100
info: <-- POST /wd/hub/session 303 17171.162 ms - 74
info: --> GET /wd/hub/session/49f05887-f391-c568-026d-2738896ef100 {}
info: [debug] Proxying command to localhost:8080
info: [debug] Making http request with opts: {“url”:“http://localhost:8080/wd/hu
b/session/49f05887-f391-c568-026d-2738896ef100”,“method”:“GET”}
info: [debug] Responding to client with error: {“status”:13,“value”:{“message”:"
An unknown server-side error occurred while processing the command.",“origValue”
:“Did not successfully proxy server command”},“sessionId”:“49f05887-f391-c568-02
6d-2738896ef100”}
info: <-- GET /wd/hub/session/49f05887-f391-c568-026d-2738896ef100 500 14.443 ms

  • 210
    info: [debug] [SELENDROID] MediaRouter.RouteInfo{ uniqueId=android/.support.v7.m
    edia.SystemMediaRouteProvider:DEFAULT_ROUTE, name=Phone, description=null, enabl
    ed=true, connecting=false, playbackType=0, playbackStream=3, volumeHandling=1, v
    olume=0, volumeMax=15, presentationDisplayId=-1, extras=null, providerPackageNam
    e=android }
    info: [debug] [SELENDROID] setSystemUiVisibility(0x0)
    info: [debug] Didn’t get a new command in 60 secs, shutting down…
    info: Shutting down appium session
    info: [debug] Stopping selendroid server
    info: [debug] Making http request with opts: {“url”:“http://localhost:8080/wd/hu
    b/session/49f05887-f391-c568-026d-2738896ef100”,“method”:“DELETE”}
    info: [debug] Cleaning up appium session
    info: [debug] We shut down because no new commands came in
    info: [debug] [SELENDROID] Noti Alert - mSystemReady:true, AlertEnabled:true
    info: [debug] [SELENDROID] Noti Alert - mSystemReady:true, AlertEnabled:true
    info: [debug] [SELENDROID] Noti Alert - mSystemReady:true, AlertEnabled:true
    info: [debug] [SELENDROID] Noti Alert - mSystemReady:true, AlertEnabled:true
    info: [debug] [SELENDROID] Noti Alert - mSystemReady:true, AlertEnabled:true
    info: [debug] [SELENDROID] Noti Alert - mSystemReady:true, AlertEnabled:true
    info: [debug] [SELENDROID] Noti Alert - mSystemReady:true, AlertEnabled:true
    info: [debug] [SELENDROID] Noti Alert - mSystemReady:true, AlertEnabled:true
    info: [debug] [SELENDROID] Noti Alert - mSystemReady:true, AlertEnabled:true
    info: [debug] [SELENDROID] Noti Alert - mSystemReady:true, AlertEnabled:true
    info: [debug] [SELENDROID] Noti Alert - mSystemReady:true, AlertEnabled:true
    ^CTerminate batch job (Y/N)? y

C:\tmp>appium --app C:\tmp\hbo-android-uat-release-1.0-b1076.apk --automation-n
ame Selendroid
info: Welcome to Appium v1.4.13 (REV c75d8adcb66a75818a542fe1891a34260c21f76a)
info: Appium REST http interface listener started on 0.0.0.0:4723
info: [debug] Non-default server args: {“app”:“C:\tmp\hbo-android-uat-release-
1.0-b1076.apk”,“automationName”:“Selendroid”}
info: Console LogLevel: debug
info: --> POST /wd/hub/session {“desiredCapabilities”:{“platformName”:“ANDROID”,
“deviceName”:“1234”}}
info: Client User-Agent string: Python-urllib/3.3
info: [debug] No appActivity desired capability or server param. Parsing from ap
k.
info: [debug] No appPackage desired capability or server param. Parsing from apk
.
info: [debug] Using local app from command line: C:\tmp\hbo-android-uat-release-
1.0-b1076.apk
info: [debug] Creating new appium session 159b8351-b859-4922-b7ca-1a521ad303e7
info: [debug] Starting selendroid server
info: [debug] Getting Java version
info: Java version is: 1.8.0_31
info: [debug] Checking whether adb is present
info: [debug] Using adb from C:\Users\brian.menzies\AppData\Local\Android\sdk\pl
atform-tools\adb.exe
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: C:\Users\brian.menzies\AppData\Local\Android\sdk\pl
atform-tools\adb.exe devices
info: [debug] 1 device(s) connected
info: Found device 42f75402f2ce9fd3
info: [debug] Setting device id to 42f75402f2ce9fd3
info: [debug] Waiting for device to be ready and to respond to shell commands (t
imeout = 5)
info: [debug] executing cmd: C:\Users\brian.menzies\AppData\Local\Android\sdk\pl
atform-tools\adb.exe -s 42f75402f2ce9fd3 wait-for-device
info: [debug] executing cmd: C:\Users\brian.menzies\AppData\Local\Android\sdk\pl
atform-tools\adb.exe -s 42f75402f2ce9fd3 shell “echo ‘ready’”
info: [debug] Starting logcat capture
info: [debug] Checking whether aapt is present
info: [debug] Using aapt from C:\Users\brian.menzies\AppData\Local\Android\sdk\b
uild-tools\23.0.1\aapt.exe
info: [debug] Checking if has internet permission from manifest.
info: [debug] executing cmd: C:\Users\brian.menzies\AppData\Local\Android\sdk\bu
ild-tools\23.0.1\aapt.exe dump badging C:\tmp\hbo-android-uat-release-1.0-b1076.
apk
info: [debug] Parsing package and activity from app manifest
info: [debug] Checking whether aapt is present
info: [debug] Using aapt from C:\Users\brian.menzies\AppData\Local\Android\sdk\b
uild-tools\23.0.1\aapt.exe
info: [debug] Extracting package and launch activity from manifest.
info: [debug] executing cmd: C:\Users\brian.menzies\AppData\Local\Android\sdk\bu
ild-tools\23.0.1\aapt.exe dump badging C:\tmp\hbo-android-uat-release-1.0-b1076.
apk
info: [debug] badging package: com.hbo.android.app
info: [debug] badging act: com.hbo.android.app.activity.MainActivity
info: [debug] Parsed package and activity are: com.hbo.android.app/com.hbo.andro
id.app.activity.MainActivity
info: [debug] Rebuilt selendroid server already exists, no need to rebuild it wi
th a new manifest
info: [debug] Checking signed status of C:\Users\BRIAN~1.MEN\AppData\Local\Temp
selendroid.com.hbo.android.app.apk
info: [debug] Checking app cert for C:\Users\BRIAN~1.MEN\AppData\Local\Temp\sele
ndroid.com.hbo.android.app.apk.
info: [debug] executing cmd: java -jar C:\Users\brian.menzies\AppData\Roaming\np
m\node_modules\appium\node_modules\appium-adb\jars\verify.jar C:\Users\BRIAN~1.M
EN\AppData\Local\Temp\selendroid.com.hbo.android.app.apk
info: [debug] Checking signed status of C:\tmp\hbo-android-uat-release-1.0-b1076
.apk
info: [debug] Checking app cert for C:\tmp\hbo-android-uat-release-1.0-b1076.apk
.
info: [debug] executing cmd: java -jar C:\Users\brian.menzies\AppData\Roaming\np
m\node_modules\appium\node_modules\appium-adb\jars\verify.jar C:\tmp\hbo-android
-uat-release-1.0-b1076.apk
info: [debug] App already signed.
info: [debug] Zip-aligning C:\Users\BRIAN~1.MEN\AppData\Local\Temp\selendroid.co
m.hbo.android.app.apk
info: [debug] Checking whether zipalign is present
info: [debug] Using zipalign from C:\Users\brian.menzies\AppData\Local\Android\s
dk\build-tools\23.0.1\zipalign.exe
info: [debug] Zip-aligning apk.
info: [debug] executing cmd: C:\Users\brian.menzies\AppData\Local\Android\sdk\bu
ild-tools\23.0.1\zipalign.exe -f 4 C:\Users\BRIAN~1.MEN\AppData\Local\Temp\selen
droid.com.hbo.android.app.apk C:\Users\BRIAN~1.MEN\AppData\Local\Temp\11599-5300
-1o54im7\appium.tmp
info: [debug] App already signed.
info: [debug] Zip-aligning C:\tmp\hbo-android-uat-release-1.0-b1076.apk
info: [debug] Checking whether zipalign is present
info: [debug] Using zipalign from C:\Users\brian.menzies\AppData\Local\Android\s
dk\build-tools\23.0.1\zipalign.exe
info: [debug] Zip-aligning apk.
info: [debug] executing cmd: C:\Users\brian.menzies\AppData\Local\Android\sdk\bu
ild-tools\23.0.1\zipalign.exe -f 4 C:\tmp\hbo-android-uat-release-1.0-b1076.apk
C:\Users\BRIAN~1.MEN\AppData\Local\Temp\11599-5300-1un01el\appium.tmp
info: [debug] Rebuilt selendroid apk exists, doing nothing
info: [debug] Getting install status for com.hbo.android.app.selendroid
info: [debug] Getting device API level
info: [debug] executing cmd: C:\Users\brian.menzies\AppData\Local\Android\sdk\pl
atform-tools\adb.exe -s 42f75402f2ce9fd3 shell “getprop ro.build.version.sdk”
info: [debug] MD5 for selendroid server is 87fa75b3d0500f7a051d88e132ecc432
info: [debug] Device is at API Level 16
info: [debug] executing cmd: C:\Users\brian.menzies\AppData\Local\Android\sdk\pl
atform-tools\adb.exe -s 42f75402f2ce9fd3 shell “pm list packages -3 com.hbo.andr
oid.app.selendroid”
info: [debug] App is installed
info: [debug] Rebuilt selendroid is already installed
info: [debug] Extracting strings for language: default
info: [debug] executing cmd: C:\Users\brian.menzies\AppData\Local\Android\sdk\pl
atform-tools\adb.exe -s 42f75402f2ce9fd3 shell “getprop persist.sys.language”
info: [debug] Current device persist.sys.language:
info: [debug] java -jar “C:\Users\brian.menzies\AppData\Roaming\npm\node_modules
\appium\node_modules\appium-adb\jars\appium_apk_tools.jar” “stringsFromApk” “C:
tmp\hbo-android-uat-release-1.0-b1076.apk” “C:\Users\BRIAN~1.MEN\AppData\Local\T
emp\com.hbo.android.app”
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 C:\tmp\hbo-android-uat-release-1.0-b1076.apk
.
info: [debug] executing cmd: java -jar C:\Users\brian.menzies\AppData\Roaming\np
m\node_modules\appium\node_modules\appium-adb\jars\verify.jar C:\tmp\hbo-android
-uat-release-1.0-b1076.apk
info: [debug] App already signed.
info: [debug] Zip-aligning C:\tmp\hbo-android-uat-release-1.0-b1076.apk
info: [debug] Checking whether zipalign is present
info: [debug] Using zipalign from C:\Users\brian.menzies\AppData\Local\Android\s
dk\build-tools\23.0.1\zipalign.exe
info: [debug] Zip-aligning apk.
info: [debug] executing cmd: C:\Users\brian.menzies\AppData\Local\Android\sdk\bu
ild-tools\23.0.1\zipalign.exe -f 4 C:\tmp\hbo-android-uat-release-1.0-b1076.apk
C:\Users\BRIAN~1.MEN\AppData\Local\Temp\11599-5300-dcj2r7\appium.tmp
info: [debug] MD5 for app is 31731847d6b8c1c067c13f8fe195c0ba
info: [debug] executing cmd: C:\Users\brian.menzies\AppData\Local\Android\sdk\pl
atform-tools\adb.exe -s 42f75402f2ce9fd3 shell “ls /data/local/tmp/31731847d6b8c
1c067c13f8fe195c0ba.apk”
info: [debug] Getting install status for com.hbo.android.app
info: [debug] Getting device API level
info: [debug] executing cmd: C:\Users\brian.menzies\AppData\Local\Android\sdk\pl
atform-tools\adb.exe -s 42f75402f2ce9fd3 shell “getprop ro.build.version.sdk”
info: [debug] Device is at API Level 16
info: [debug] executing cmd: C:\Users\brian.menzies\AppData\Local\Android\sdk\pl
atform-tools\adb.exe -s 42f75402f2ce9fd3 shell “pm list packages -3 com.hbo.andr
oid.app”
info: [debug] App is installed
info: App is already installed, resetting app
info: [debug] Running fast reset (stop and clear)
info: [debug] executing cmd: C:\Users\brian.menzies\AppData\Local\Android\sdk\pl
atform-tools\adb.exe -s 42f75402f2ce9fd3 shell “am force-stop com.hbo.android.ap
p”
info: [debug] executing cmd: C:\Users\brian.menzies\AppData\Local\Android\sdk\pl
atform-tools\adb.exe -s 42f75402f2ce9fd3 shell “pm clear com.hbo.android.app”
info: [debug] Forwarding system:8080 to device:8080
info: [debug] executing cmd: C:\Users\brian.menzies\AppData\Local\Android\sdk\pl
atform-tools\adb.exe -s 42f75402f2ce9fd3 forward tcp:8080 tcp:8080
info: [debug] Pushing settings apk to device…
info: [debug] executing cmd: C:\Users\brian.menzies\AppData\Local\Android\sdk\pl
atform-tools\adb.exe -s 42f75402f2ce9fd3 install “C:\Users\brian.menzies\AppData
\Roaming\npm\node_modules\appium\build\settings_apk\settings_apk-debug.apk”
info: [debug] Pushing unlock helper app to device…
info: [debug] executing cmd: C:\Users\brian.menzies\AppData\Local\Android\sdk\pl
atform-tools\adb.exe -s 42f75402f2ce9fd3 install “C:\Users\brian.menzies\AppData
\Roaming\npm\node_modules\appium\build\unlock_apk\unlock_apk-debug.apk”
info: [debug] executing cmd: C:\Users\brian.menzies\AppData\Local\Android\sdk\pl
atform-tools\adb.exe -s 42f75402f2ce9fd3 shell “dumpsys window”
info: Unlocking screen
info: [debug] Screen is locked, trying to unlock
info: [debug] Getting device API level
info: [debug] executing cmd: C:\Users\brian.menzies\AppData\Local\Android\sdk\pl
atform-tools\adb.exe -s 42f75402f2ce9fd3 shell “getprop ro.build.version.sdk”
info: [debug] Device is at API Level 16
info: [debug] executing cmd: C:\Users\brian.menzies\AppData\Local\Android\sdk\pl
atform-tools\adb.exe -s 42f75402f2ce9fd3 shell “am start -S -a android.intent.ac
tion.MAIN -c android.intent.category.LAUNCHER -f 0x10200000 -n io.appium.unlock/
.Unlock”
info: [debug] executing cmd: C:\Users\brian.menzies\AppData\Local\Android\sdk\pl
atform-tools\adb.exe -s 42f75402f2ce9fd3 shell “dumpsys window”
info: [debug] Screen is unlocked, continuing
info: [debug] executing cmd: C:\Users\brian.menzies\AppData\Local\Android\sdk\pl
atform-tools\adb.exe -s 42f75402f2ce9fd3 shell “am instrument -e main_activity ’
com.hbo.android.app.activity.MainActivity’ com.hbo.android.app.selendroid/io.sel
endroid.server.ServerInstrumentation”
info: [debug] Making http request with opts: {“url”:“http://localhost:8080/wd/hu
b/status”,“method”:“GET”}
info: [debug] Making http request with opts: {“url”:“http://localhost:8080/wd/hu
b/status”,“method”:“GET”}
info: [debug] Selendroid server is alive!
info: [debug] Listening for Selendroid logs
info: [debug] Creating Selendroid session
info: [debug] Making http request with opts: {“url”:“http://localhost:8080/wd/hu
b/session”,“method”:“POST”,“json”:{“desiredCapabilities”:{“warnings”:{},“desired
“:{“platformName”:“ANDROID”,“deviceName”:“1234”},“platformName”:“ANDROID”,“devic
eName”:“1234”}}}
info: [debug] Successfully started selendroid session
info: [debug] Waiting for pkg “com.hbo.android.app” and activity “com.hbo.androi
d.app.activity.MainActivity” to be focused
info: [debug] Getting focused package and activity
info: [debug] executing cmd: C:\Users\brian.menzies\AppData\Local\Android\sdk\pl
atform-tools\adb.exe -s 42f75402f2ce9fd3 shell “dumpsys window windows”
info: [debug] [SELENDROID] setSystemUiVisibility(0x0)
info: [debug] Getting focused package and activity
info: [debug] executing cmd: C:\Users\brian.menzies\AppData\Local\Android\sdk\pl
atform-tools\adb.exe -s 42f75402f2ce9fd3 shell “dumpsys window windows”
info: [debug] Getting focused package and activity
info: [debug] executing cmd: C:\Users\brian.menzies\AppData\Local\Android\sdk\pl
atform-tools\adb.exe -s 42f75402f2ce9fd3 shell “dumpsys window windows”
info: [debug] Getting focused package and activity
info: [debug] executing cmd: C:\Users\brian.menzies\AppData\Local\Android\sdk\pl
atform-tools\adb.exe -s 42f75402f2ce9fd3 shell “dumpsys window windows”
error: com.hbo.android.app/.activity.MainActivity never started. Current: com.hb
o.android.app/.SignInActivity
info: [debug] Selendroid hasn’t started app yet, let’s do it manually with adb.s
tartApp
info: [debug] Getting device API level
info: [debug] executing cmd: C:\Users\brian.menzies\AppData\Local\Android\sdk\pl
atform-tools\adb.exe -s 42f75402f2ce9fd3 shell “getprop ro.build.version.sdk”
info: [debug] Device is at API Level 16
info: [debug] executing cmd: C:\Users\brian.menzies\AppData\Local\Android\sdk\pl
atform-tools\adb.exe -s 42f75402f2ce9fd3 shell “am start -S -a android.intent.ac
tion.MAIN -c android.intent.category.LAUNCHER -f 0x10200000 -n com.hbo.android.a
pp/com.hbo.android.app.activity.MainActivity”
info: [debug] [SELENDROID] setSystemUiVisibility(0x0)
info: [debug] Waiting for pkg “com.hbo.android.app” and activity “com.hbo.androi
d.app.activity.MainActivity” to be focused
info: [debug] Getting focused package and activity
info: [debug] executing cmd: C:\Users\brian.menzies\AppData\Local\Android\sdk\pl
atform-tools\adb.exe -s 42f75402f2ce9fd3 shell “dumpsys window windows”
info: [debug] Overriding session id with “1c406e1c-72b1-baa1-233d-f2133f5fb1d0”
info: [debug] Device launched! Ready for commands
info: [debug] Setting command timeout to the default of 60 secs
info: [debug] Appium session started with sessionId 1c406e1c-72b1-baa1-233d-f213
3f5fb1d0
info: <-- POST /wd/hub/session 303 13179.388 ms - 74
info: --> GET /wd/hub/session/1c406e1c-72b1-baa1-233d-f2133f5fb1d0 {}
info: [debug] Proxying command to localhost:8080
info: [debug] Making http request with opts: {“url”:“http://localhost:8080/wd/hu
b/session/1c406e1c-72b1-baa1-233d-f2133f5fb1d0”,“method”:“GET”}
info: [debug] Responding to client with error: {“status”:13,“value”:{“message”:”
An unknown server-side error occurred while processing the command.”,“origValue”
:“Did not successfully proxy server command”},“sessionId”:“1c406e1c-72b1-baa1-23
3d-f2133f5fb1d0”}
info: <-- GET /wd/hub/session/1c406e1c-72b1-baa1-233d-f2133f5fb1d0 500 14.023 ms

  • 210
    info: [debug] [SELENDROID] MediaRouter.RouteInfo{ uniqueId=android/.support.v7.m
    edia.SystemMediaRouteProvider:DEFAULT_ROUTE, name=Phone, description=null, enabl
    ed=true, connecting=false, playbackType=0, playbackStream=3, volumeHandling=1, v
    olume=0, volumeMax=15, presentationDisplayId=-1, extras=null, providerPackageNam
    e=android }
    info: [debug] [SELENDROID] setSystemUiVisibility(0x0)

Any ideas on what I should do to make it work? The app and the service are both signed by me and I’ve deleted and reinstalled the service and re-downloaded the unsigned app numerous times. Any help is greatly appreciated.

and the weird thing is that the app will be downloaded to the phone if it isn’t there already, open, then immediately close and re-open and show an error message in PyCharm.