Appium with android device

Trying to setup Appium with Android but keep getting errors. I have an APK manually installed to an actual device. I have followed the instructions on the error message with no luck.

My Desired capabilities are set to:

“appPackage”: “com.XYZ.android”,
“appActivity”: “com.XYZ.android.homepage.HomePageActivity”,
“platformName”: “Android”, “deviceName”:
“Google Pixel 3a”,
“udid”: “99NBY3DL9K”,
“automationName”: “UiAutomator2”,

Get this error:

An unknown server-side error occurred while processing the command. Original error: Cannot start the ‘com.XYZ.android.debug’ application. Visit https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/android/activity-startup.md for troubleshooting. Original error: Error executing adbExec. Original error: ‘Command ‘/Users/pops/Library/Android/sdk/platform-tools/adb -P 5037 -s 99NBY3DL9K shell am start -W -n com.XYZ.android.debug/com.XYZ.android.homepage.HomePageActivity -S’ exited with code 255’; Stderr: ‘Exception occurred while executing ‘start’: java.lang.SecurityException: Permission Denial: starting Intent { flg=0x10000000 cmp=com.XYZ.android.debug/com.XYZ.android.homepage.HomePageActivity } from null (pid=7171, uid=2000) not exported from uid 10304 at com.android.server.wm.ActivityStackSupervisor.checkStartAnyActivityPermission(ActivityStackSupervisor.java:1043) at com.android.server.wm.ActivityStarter.executeRequest(ActivityStarter.java:999) at com.android.server.wm.ActivityStarter.execute(ActivityStarter.java:669) at com.android.server.wm.ActivityTaskManagerService.startActivityAndWait(ActivityTaskManagerService.java:1334) at com.android.server.am.ActivityManagerService.startActivityAndWait(ActivityManagerService.java:3671) at com.android.server.am.ActivityManagerShellCommand.runStartActivity(ActivityManagerShellCommand.java:539) at com.android.server.am.ActivityManagerShellCommand.onCommand(ActivityManagerShellCommand.java:186) at android.os.BasicShellCommandHandler.exec(BasicShellCommandHandler.java:98) at android.os.ShellCommand.exec(ShellCommand.java:44) at com.android.server.am.ActivityManagerService.onShellCommand(ActivityManagerService.java:10504) at android.os.Binder.shellCommand(Binder.java:929) at android.os.Binder.onTransact(Binder.java:813) at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:5053) at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2867) at android.os.Binder.execTransactInternal(Binder.java:1159) at android.os.Binder.execTransact(Binder.java:1123)’; Code: ‘255’ …

The error and possible solution is documented here:
http://appium.io/docs/en/writing-running-appium/android/activity-startup/

Have you tried inspecting the device thru appium desktop? You can try adding the minimum desired cap and see if you can open the device then check the logs for the detected appPackage and appActivity

 "platformName": "Android",
 "platformVersion": "11",
 "deviceName": "Pixel_3a_API_30_x86",
 "app": "<app location>"
 “automationName”: “UiAutomator2”,

Thanks. Tried that but it didn’t work

sorry it did work, thanks. But how to access the installed app then?

BTW I know the app package and activity using-

adb shell dumpsys window windows

but when i enter them in the desired capabilities it throws the error

“app”: “” ?

For the app i entered :

“appPackage”: “com.XYZ.android.debug”,

Am I suppose to enter “app” ?