Main activity launches too quickly so Appium doesn't recognize it

I’m having an issue where my main activity launches and moves to the next activity so quickly, that appium thinks it never launches.

[debug] [ADB] Found package: ‘com.XXXX.XXXXX.internal’ and fully qualified activity name : ‘com.XXX.XXXX.ui.onboarding.OnboardingActivity’
[debug] [ADB] Incorrect package and activity. Retrying.
[ADB] Error: Error occured while starting App. Original error: ‘com.XXX.XXXXXX.ui.launch.LaunchActivity’ never started

What is happening is that the LaunchActivity is launching, but it’s going so fast Appium never recognizes this. I can verify this by adding a wait in LaunchActivity. Unfortunately this is not a long term solution. I tried fixing by setting the app and package capability to OnboardingActivity, however, that doesn’t work because I get a permission denial error. I talked to the developer to get this fixed but they don’t want this activity launch-able in the production build of the app.

Does Appium have any other capabilities to help me out here?

Make sure you are giving lauchable activity to appium to launch.

Hi farnett,

Could you try setting your LaunchActivity to “appActivity” and your package name to “appWaitPackage” and see if that works?

Let us know if this works for you.

I have tried

capabilities.setCapability("appPackage","com.XXXX");
capabilities.setCapability("appActivity","com.XXXX.ui.ui.launch.LaunchActivity");

capabilities.setCapability("appPackage","com.XXXX");
capabilities.setCapability("appActivity","com.XXXX.ui.onboarding.OnboardingActivity");

and now

capabilities.setCapability("appWaitPackage","com.XXXX");
capabilities.setCapability("appActivity","com.XXXX.ui.onboarding.OnboardingActivity");

capabilities.setCapability("appWaitPackage","com.XXXX");
capabilities.setCapability("appActivity","com.XXXX.ui.LaunchActivity");

none of which have worked. I either get an activity never launched error with LaunchActivity or a permission denial error with OnBoardingActivity

The problem I’m running into is it is not recognizing the launch-able activity, it goes too fast. Instead it just complains that the launch-able activity never started. If I delay the activity moving onto the next activity, everything is fine.

It seems that you need both “waits” and then it will paused until the activity comes into focus. This ended up fixing my problem, thanks!

capabilities.setCapability("appWaitPackage","com.XXXX");
capabilities.setCapability("appWaitActivity","com.XXXX.ui.LaunchActivity");

@farnett better use:

capabilities.setCapability("appWaitActivity","com.XXXX.*");

and forget about activity naming. starting from appium 1.5 about