Appium showing error while launch app in android with activity name

Appium showing error with activity name.

capabilities.setCapability(MobileCapabilityType.DEVICE_NAME,“Android device”);
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME,“MobilePlatform.ANDROID”);
capabilities.setCapability(“appPackage”, “com.diro”);
capabilities.setCapability(“appActivity”, “tutorial.MainActivity”);
//capabilities.setCapability(“appActivity”, “directory_new_ui.Directory_Home”);
capabilities.setCapability(“noReset”, true);
capabilities.setCapability(“fullReset”, false);
// directory_new_ui.Directory_Home
//other caps
capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, “”);
capabilities.setCapability(MobileCapabilityType.VERSION, “5.1.1.”);
capabilities.setCapability(MobileCapabilityType.PLATFORM, “MAC”);
capabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, “100”);
// capabilities.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());
driver = new AndroidDriver(new URL(“http://127.0.0.1:4723/wd/hub”) , capabilities);
// driver.manage().timeouts().implicitlyWait(120, TimeUnit.SECONDS);
driver.startActivity(“com.diro”,“tutorial.MainActivity”);
driver.startActivity(“com.diro”, “directory_new_ui.Directory_Home”);

Logs—

error: Failed to start an Appium session, err was: Error: com.diro/tutorial.MainActivity never started. Current: com.diro/directory_new_ui.Directory_Home

info: [debug] UiAutomator shut down normally
info: [debug] Cleaning up android objects
info: [debug] Cleaning up appium session
info: [debug] Error: com.diro/tutorial.MainActivity never started. Current: com.diro/directory_new_ui.Directory_Home
at [object Object]. (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-adb/lib/adb.js:1314:12)
at [object Object]. (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-adb/lib/adb.js:1258:7)
at [object Object]. (/Applications/Appium.app/Contents/Resources/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:1015:16)
at Socket. (child_process.js:1183:11)
at Socket.emit (events.js:107:17)
at Pipe.close (net.js:485:12)
info: [debug] Responding to client with error: {“status”:33,“value”:{“message”:“A new session could not be created. (Original error: com.diro/tutorial.MainActivity never started. Current: com.diro/directory_new_ui.Directory_Home)”,“origValue”:“com.diro/tutorial.MainActivity never started. Current: com.diro/directory_new_ui.Directory_Home”},“sessionId”:null}
info: <-- POST /wd/hub/session 500 27294.470 ms - 312

info: --> GET /wd/hub/status {}

Hey there,
So it looks like uiautomator couldn’t find your activity:
What I would do is to find all of your app’s possible activity values by using aapt. You’ll find this tool in your $ANDROID_HOME/sdk build tools directory

Here’s what I run locally:

~/Library/Android/sdk/build-tools/21.1.2/aapt dump --values xmltree YOUR.apk AndroidManifest.xml > temp.txt

I open up my output (temp.txt) in this case and search on “Activity”. I add all of these to my appWaitActivity desired capability.

Since doing that I haven’t seen series such as yours come back.

Thanks
Eric

Hello ,
thanks eric for reply .
Actually the problem is ,i am trying to launch app without reinstall for script development because have to run test cases again and again but “tutorial.main” is mine launcher activity and i performing function on “directory_new_ui.Directory_Home”. First time my test case are running well but after rerun its showing same error which is mention above in logs.
i also used appWaitActivity but still not resolved
Please help me how to do

Not sure offhand:

  1. Make sure this is in your appWaitActivity (sounds like it is)
    com.diro/directory_new_ui.Directory_Home

  2. Make sure you are running appium with --no-reset

  3. If you launch arc, execute your script piecemeal. Then at some point type restart. See if you get your error again.

Let me know and we’ll go from there

Thanks Shermaneric,

But still facing same problem with appWaitActivity pls find below code and error logs.

DesiredCapabilities capabilities = new DesiredCapabilities();
//mandatory capabilities
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME,“Android device”);
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME,“MobilePlatform.ANDROID”);
capabilities.setCapability(“appPackage”, “com.diro”);
capabilities.setCapability(“appActivity”, “tutorial.MainActivity”);
// capabilities.setCapability(“appWaitActivity”, “tutorial.MainActivity”);
capabilities.setCapability(“appWaitActivity”, “directory_new_ui.Directory_Home”);
capabilities.setCapability(“noReset”, true);
capabilities.setCapability(“fullReset”, false);
// directory_new_ui.Directory_Home
//other caps
capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, “”);
capabilities.setCapability(MobileCapabilityType.VERSION, “5.1.1.”);
capabilities.setCapability(MobileCapabilityType.PLATFORM, “MAC”);
capabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, “100”);
// capabilities.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());

	driver  = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub") , capabilities);
 driver.manage().timeouts().implicitlyWait(120, TimeUnit.SECONDS);
               driver.startActivity("com.diro","tutorial.MainActivity");

Logs:-

info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: current=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: 1
info: [debug] [BOOTSTRAP] [debug] Socket opened on port 4724
info: [debug] [BOOTSTRAP] [debug] Appium Socket Server Ready
info: [debug] [BOOTSTRAP] [debug] Loading json…
info: [debug] [BOOTSTRAP] [debug] Registered crash watchers.
info: [debug] Waking up device if it’s not alive
info: [debug] Pushing command to appium work queue: [“wake”,{}]
info: [debug] [BOOTSTRAP] [debug] Client connected
info: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“action”,“action”:“wake”,“params”:{}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: wake
info: [debug] [BOOTSTRAP] [debug] Returning result: {“value”:true,“status”:0}
info: [debug] executing cmd: /Users/srikanta_Dirolabs/android-sdks/platform-tools/adb -s 2fe5e57 shell “dumpsys window”
info: [debug] Screen already unlocked, continuing.
info: [debug] Pushing command to appium work queue: [“getDataDir”,{}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“action”,“action”:“getDataDir”,“params”:{}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: getDataDir
info: [debug] [BOOTSTRAP] [debug] Returning result: {“value”:"/data/local/tmp",“status”:0}
info: [debug] dataDir set to: /data/local/tmp
info: [debug] Pushing command to appium work queue: [“compressedLayoutHierarchy”,{“compressLayout”:false}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“action”,“action”:“compressedLayoutHierarchy”,“params”:{“compressLayout”:false}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: compressedLayoutHierarchy
info: [debug] Getting device API level
info: [debug] executing cmd: /Users/srikanta_Dirolabs/android-sdks/platform-tools/adb -s 2fe5e57 shell “getprop ro.build.version.sdk”
info: [debug] [BOOTSTRAP] [debug] Returning result: {“value”:false,“status”:0}
info: [debug] Device is at API Level 19
info: [debug] executing cmd: /Users/srikanta_Dirolabs/android-sdks/platform-tools/adb -s 2fe5e57 shell “am start -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000 -n com.diro/tutorial.MainActivity”
info: [debug] Waiting for pkg “com.diro” and activity “directory_new_ui.Directory_Home” to be focused
info: [debug] Getting focused package and activity
info: [debug] executing cmd: /Users/srikanta_Dirolabs/android-sdks/platform-tools/adb -s 2fe5e57 shell “dumpsys window windows”
info: [debug] Getting focused package and activity
info: [debug] executing cmd: /Users/srikanta_Dirolabs/android-sdks/platform-tools/adb -s 2fe5e57 shell “dumpsys window windows”
info: [debug] Getting focused package and activity
info: [debug] executing cmd: /Users/srikanta_Dirolabs/android-sdks/platform-tools/adb -s 2fe5e57 shell “dumpsys window windows”
info: [debug] Getting focused package and activity
info: [debug] executing cmd: /Users/srikanta_Dirolabs/android-sdks/platform-tools/adb -s 2fe5e57 shell “dumpsys window windows”
info: [debug] Getting focused package and activity
info: [debug] executing cmd: /Users/srikanta_Dirolabs/android-sdks/platform-tools/adb -s 2fe5e57 shell “dumpsys window windows”
info: [debug] Getting focused package and activity
info: [debug] executing cmd: /Users/srikanta_Dirolabs/android-sdks/platform-tools/adb -s 2fe5e57 shell “dumpsys window windows”
info: [debug] Getting focused package and activity
info: [debug] executing cmd: /Users/srikanta_Dirolabs/android-sdks/platform-tools/adb -s 2fe5e57 shell “dumpsys window windows”
info: [debug] executing cmd: /Users/srikanta_Dirolabs/android-sdks/platform-tools/adb -s 2fe5e57 shell “getprop ro.build.version.release”
info: [debug] Device is at release version 4.4.4
info: [debug] Device launched! Ready for commands
info: [debug] Setting command timeout to 100 secs
info: [debug] Appium session started with sessionId 7717b850-b6d8-4510-8f76-acbcd3e8211b
info: <-- POST /wd/hub/session 303 13876.182 ms - 74
info: --> GET /wd/hub/session/7717b850-b6d8-4510-8f76-acbcd3e8211b {}
info: [debug] Responding to client with success: {“status”:0,“value”:{“platform”:“MAC”,“browserName”:"",“platformVersion”:“4.4.4”,“webStorageEnabled”:false,“takesScreenshot”:true,“javascriptEnabled”:true,“databaseEnabled”:false,“networkConnectionEnabled”:true,“locationContextEnabled”:false,“warnings”:{},“desired”:{“appPackage”:“com.diro”,“appActivity”:“tutorial.MainActivity”,“noReset”:true,“newCommandTimeout”:“100”,“appWaitActivity”:“directory_new_ui.Directory_Home”,“browserName”:"",“platformName”:“Android”,“deviceName”:“Android device”,“fullReset”:false,“version”:“5.1.1.”,“platform”:“MAC”},“appPackage”:“com.diro”,“appActivity”:“tutorial.MainActivity”,“noReset”:true,“newCommandTimeout”:“100”,“appWaitActivity”:“directory_new_ui.Directory_Home”,“platformName”:“Android”,“deviceName”:“2fe5e57”,“fullReset”:false,“version”:“5.1.1.”},“sessionId”:“7717b850-b6d8-4510-8f76-acbcd3e8211b”}
info: <-- GET /wd/hub/session/7717b850-b6d8-4510-8f76-acbcd3e8211b 200 5.232 ms - 841 {“status”:0,“value”:{“platform”:“MAC”,“browserName”:"",“platformVersion”:“4.4.4”,“webStorageEnabled”:false,“takesScreenshot”:true,“javascriptEnabled”:true,“databaseEnabled”:false,“networkConnectionEnabled”:true,“locationContextEnabled”:false,“warnings”:{},“desired”:{“appPackage”:“com.diro”,“appActivity”:“tutorial.MainActivity”,“noReset”:true,“newCommandTimeout”:“100”,“appWaitActivity”:“directory_new_ui.Directory_Home”,“browserName”:"",“platformName”:“Android”,“deviceName”:“Android device”,“fullReset”:false,“version”:“5.1.1.”,“platform”:“MAC”},“appPackage”:“com.diro”,“appActivity”:“tutorial.MainActivity”,“noReset”:true,“newCommandTimeout”:“100”,“appWaitActivity”:“directory_new_ui.Directory_Home”,“platformName”:“Android”,“deviceName”:“2fe5e57”,“fullReset”:false,“version”:“5.1.1.”},“sessionId”:“7717b850-b6d8-4510-8f76-acbcd3e8211b”}
info: --> POST /wd/hub/session/7717b850-b6d8-4510-8f76-acbcd3e8211b/timeouts/implicit_wait {“ms”:120000}
info: [debug] Set Android implicit wait to 120000ms
info: [debug] Responding to client with success: {“status”:0,“value”:null,“sessionId”:“7717b850-b6d8-4510-8f76-acbcd3e8211b”}
info: <-- POST /wd/hub/session/7717b850-b6d8-4510-8f76-acbcd3e8211b/timeouts/implicit_wait 200 2.839 ms - 76 {“status”:0,“value”:null,“sessionId”:“7717b850-b6d8-4510-8f76-acbcd3e8211b”}
info: --> POST /wd/hub/session/7717b850-b6d8-4510-8f76-acbcd3e8211b/appium/device/start_activity {“appPackage”:“com.diro”,“appActivity”:“tutorial.MainActivity”,“appWaitPackage”:"",“appWaitActivity”:""}
info: [debug] Getting device API level
info: [debug] executing cmd: /Users/srikanta_Dirolabs/android-sdks/platform-tools/adb -s 2fe5e57 shell “getprop ro.build.version.sdk”
info: [debug] Device is at API Level 19
info: [debug] executing cmd: /Users/srikanta_Dirolabs/android-sdks/platform-tools/adb -s 2fe5e57 shell “am start -S -n com.diro/tutorial.MainActivity”
info: [debug] Responding to client with success: {“status”:0,“value”:“Successfully launched the app.”,“sessionId”:“7717b850-b6d8-4510-8f76-acbcd3e8211b”}
info: <-- POST /wd/hub/session/7717b850-b6d8-4510-8f76-acbcd3e8211b/appium/device/start_activity 200 1015.986 ms - 104 {“status”:0,“value”:“Successfully launched the app.”,“sessionId”:“7717b850-b6d8-4510-8f76-acbcd3e8211b”}

i am executing as piecemeal script and using both
capabilities.setCapability(“noReset”, true);
capabilities.setCapability(“fullReset”, false);
but not done for me.

Hmm your last log didn’t have the error?
{“status”:0,“value”:“Successfully launched the app.”,“sessionId”:“7717b850-b6d8-4510-8f76-acbcd3e8211b”}

In your last post I didn’t see the com.diro/ prefix. I use mine. Not sure if it’s necessary

Note: you can comma delimit multiple appWaitActivites. - sometimes depending on what state your app is in there may be a different activity to wait on. Use the aforementioned aapt command above for details.

Otherwise is it possible to send the apk over? I can take a closer look

Thanks
Eric

Yes its launching the app by mine main activity “tutorial.MainActivity” but after launching its not running script. i have to work on “directory_new_ui.Directory_Home” activity.i also used multiple appWaitActivity.

capabilities.setCapability(MobileCapabilityType.APP_ACTIVITY,“tutorial.MainActivity”);
capabilities.setCapability(MobileCapabilityType.APP_WAIT_ACTIVITY,“directory_new_ui.Directory_Home”);

Hi @pushpank
Sorry you have not gotten your issue solved yet.
Here’s the remaining thoughts I have.

  1. I do not have noReset nor fullReset listed in my device’s desired capabilities. I have this:

platformName = “Android”
platformVersion = “4.4”
deviceName = “Android Emulator”
appPackage = “com.blackboard.android.bbstudent”
appActivity = “com.blackboard.android.bblearnshared.activity.LaunchActivity”
appWaitActivity = “com.blackboard.android.bblearnshared.login.activity.LoginActivity, com.blackboard.android.bblearnshared.navigation.activity.NavigationActivityPhone”
app = “apps/android-bbstudent-debug.apk”

[appium_lib]
port = 4900

  1. I start the Appium Server initially like this (with --no-reset)
appium -a localhost -p $android_appium_port -bp $android_appium_bootstrap_port --no-reset

3 Similar problems existed in this issue found here. You may want to check to see if similar things apply.

  1. The only last thing again I can recommend is that you send me your APK if that’s possible at all and I can have a look? Otherwise, I’m flat out of ideas and perhaps someone else can assist.

good luck!
Eric