APX403
October 7, 2023, 8:06pm
1
Hello!
I struggle using the StartActivity function in C#
I’m able to start the android driver with the following code :
AppiumOptions options = new AppiumOptions();
options.PlatformName = "Android";
options.AddAdditionalCapability("deviceName", name);
options.AddAdditionalCapability("platformVersion", "12.0");
options.AddAdditionalCapability("newCommandTimeout", "86400");
options.AddAdditionalCapability("noReset", "true");
options.AddAdditionalCapability("udid", serial);
options.AddAdditionalCapability("appPackage", "com.instagram.android");
options.AddAdditionalCapability("appActivity", "com.instagram.android.activity.MainTabActivity");
localDriver = new AndroidDriver<AndroidElement>(service.ServiceUrl, options, TimeSpan.FromSeconds(180));
localDriver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(30);
But when I try with the following code, I got an error :
AppiumOptions options = new AppiumOptions();
options.PlatformName = "Android";
options.AddAdditionalCapability("deviceName", name);
options.AddAdditionalCapability("platformVersion", "12.0");
options.AddAdditionalCapability("newCommandTimeout", "86400");
options.AddAdditionalCapability("noReset", "true");
options.AddAdditionalCapability("udid", serial);
localDriver = new AndroidDriver<AndroidElement>(service.ServiceUrl, options, TimeSpan.FromSeconds(180));
localDriver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(30);
localDriver.StartActivity("com.instagram.android", "com.instagram.android.activity.MainTabActivity");
The error :
An unknown server-side error occurred while processing the command. Original error: Cannot start the 'com.instagram.android' application. Visit https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/android/activity-startup.md for troubleshooting. Original error: 'com.instagram.android.activity.MainTabActivity' never started. Visit https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/android/activity-startup.md for troubleshooting
Do you have any idea what the problem could be?
Thanks a lot for your help!
wreed
October 9, 2023, 2:06am
2
This is a bad url. Are you using Appium 1? Here’s the proper one for Appium 2:
## How To Troubleshoot Activities Startup
### Capabilities
> The Activity class is a crucial component of an Android app, and the way activities are launched and put together is a fundamental part of the platform's application model. Unlike programming paradigms in which apps are launched with a main() method, the Android system initiates code in an Activity instance by invoking specific callback methods that correspond to specific stages of its lifecycle.
> © [Android Developer Documentation](https://developer.android.com/guide/components/activities/intro-activities)
Appium needs to know package and activity names in order to properly initialize the application under test. This information is expected to be provided in driver capabilities and consists of the following keys:
- `appActivity`: The name of the main application activity
- `appPackage`: The identifier of the application package
- `appWaitActivity`: The name of the application activity to wait for/which starts the first
- `appWaitPackage`: The id of the application package to wait for/which starts the first
- `appWaitDuration`: The maximum duration to wait until the `appWaitActivity` is focused in milliseconds (20000 by default)
- `appWaitForLaunch`: Whether to wait until Activity Manager returns the control to the calling process. By default the driver always waits until `appWaitDuration` is expired. Setting this capability to `false` effectively cancels this wait and unblocks the server loop as soon as `am` successfully triggers the command to start the activity.
All these capabilities are optional. If they are not set explicitly then Appium tries to auto detect them by reading their values from the APK manifest. Although, if the application under test is supposed to be already installed on the device (`noReset=true`) then at least `appActivity` and `appPackage` options are required to be set, since no package manifest is available in such case. If you don't set `appWaitPackage` and `appWaitActivity` explicitly then these are getting assigned to `appPackage`/`appActivity` values automatically. For more details check on the implementation of `packageAndLaunchActivityFromManifest` method in the [appium-adb](https://github.com/appium/appium-adb/blob/master/lib/tools/android-manifest.js) package.
This file has been truncated. show original
@APX403 , if you are using appium 2, please update your client to version 5.