Original error: Activity name '.in.helloparent.teacher.activities.SplashActivity' used to start the app doesn't exist or cannot be launched!

Hi ,

I am getting below error:
Original error: Activity name ‘.in.helloparent.teacher.activities.SplashActivity’ used to start the app doesn’t exist or cannot be launched!

Please note:
my test case first executes on the old app on real device and then on the new app in an emulator

Below is my driver code
File appDir = new File(“src”); File app = new File(appDir,
“app-debug (3).apk”);

	DesiredCapabilities capabilities = new DesiredCapabilities();
	capabilities.setCapability("deviceName", "My Phone");
	capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, "uiautomator2");
	capabilities.setCapability("platformName", "Android");
	capabilities.setCapability("platformVersion", "9.0");
	
	
	  if (deviceId.contains("emulator")) {
	  capabilities.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());
	  } else {
	 
	 
		capabilities.setCapability("appPackage", "in.helloparent.teacher");
		capabilities.setCapability("appActivity", activity);
	}
	capabilities.setCapability("noReset", true);
	driver = new AndroidDriver<AndroidElement>(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
	return driver;

@Aleksei Can you help here

Just try to set “*” for actuvity and Appium will choose any started

i tried by writing
capabilities.setCapability(“appActivity”, “*”);

but appium appended . before it as well
@Aleksei

Enable appium server debug logs. Check what activity it sees instead.

And mention APP path in any case. When app not installed on phone appium will install it.

I assume only appWaitActivity could be set to *
This is also described in https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/android/activity-startup.md

Yes! Just missed correct name. Just config looks strange. For emulator do install/or take config from apk file but for device start app by given package and activity. I suspect that it should be same for both cases.
use better for both cases (emulator and phone):

capabilities.setCapability(MobileCapabilityType.APP, appFile.getAbsolutePath());
capabilities.setCapability(AndroidMobileCapabilityType.APP_WAIT_ACTIVITY, "*");

on emulator i have newer version of app and on real device i have older version of app.I am comparing the outputs of both apps

public static AndroidDriver Capabilities(String deviceId, String activity) throws IOException {

	DesiredCapabilities capabilities = new DesiredCapabilities();
	capabilities.setCapability("deviceName", "My Phone");
	capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, "uiautomator2");
	capabilities.setCapability("platformName", "Android");
	capabilities.setCapability("platformVersion", "9.0");
	capabilities.setCapability("appPackage", "in.helloparent.teacher");
	capabilities.setCapability("appActivity", activity);
	capabilities.setCapability("appWaitActivity", "*");
	// }
	capabilities.setCapability("noReset", true);
	driver = new AndroidDriver<AndroidElement>(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
	return driver;

}

@Aleksei if i use this still it doesnt work

we need appium logs in debug mode here -> https://gist.github.com/

ok. possibilities to solve:

  1. run it with emulator and Appium logs enabled to debug. in such case Appium will take activity name from APK file. check logs what activity taken.
  2. run Android studio and open logcat logs. run app manually on phone. check logcat logs what activities started.

PS also double check in above tries logs that full activity looks like you trying ->

in.helloparent.teacher/in.helloparent.teacher.view.SplashActivity

@Aleksei The issue is when i have both my real device connected to the laptop and emulator started, appium calls in.helloparent.teacher.view.SplashActivity on the real device but it should call it on emulator

resolved the issue by setting the udid field of desired capabilities.I set it up to emulator when i wanted to run in.helloparent.teacher/in.helloparent.teacher.view.SplashActivity activity

Thanks