I have looked all over stackoverflow and the web for a fix to this but nothing has worked.
I am trying to connect Appium Inspector to an Android Simulator but keep getting the following error
Exception occurred while executing 'start':
java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.MyApp.package/.MyApp.Activity } from null (pid=8343, uid=2000) not exported from uid 10162
at com.android.server.wm.ActivityTaskSupervisor.checkStartAnyActivityPermission(ActivityTaskSupervisor.java:1110)
at com.android.server.wm.ActivityStarter.executeRequest(ActivityStarter.java:1024)
at com.android.server.wm.ActivityStarter.execute(ActivityStarter.java:713)
at com.android.server.wm.ActivityTaskManagerService.startActivityAndWait(ActivityTaskManagerService.java:1562)
at com.android.server.am.ActivityManagerService.startActivityAndWait(ActivityManagerService.java:3148)
at com.android.server.am.ActivityManagerShellCommand.runStartActivity(ActivityManagerShellCommand.java:598)
at com.android.server.am.ActivityManagerShellCommand.onCommand(ActivityManagerShellCommand.java:208)
at com.android.modules.utils.BasicShellCommandHandler.exec(BasicShellCommandHandler.java:97)
at android.os.ShellCommand.exec(ShellCommand.java:38)
at com.android.server.am.ActivityManagerService.onShellCommand(ActivityManagerService.java:9197)
at android.os.Binder.shellCommand(Binder.java:1049)
at android.os.Binder.onTransact(Binder.java:877)
at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:4731)
at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2630)
at android.os.Binder.execTransactInternal(Binder.java:1285)
at android.os.Binder.execTransact(Binder.java:1244)
I am using the following config in Appium
{
"appium:deviceName": "Test",
"appium:udid": "emulator-5554",
"platformName": "Android",
"appium:platformVersion": "9",
"appium:automationName": "UiAutomator2",
"appium:appPackage": "com.MyApp.package",
"appium:appActivity": "com.MyApp.package.MyApp.Activity",
"appium:noReset": "true"
}
It has something to do with the application itself, my app was installed on the simulator by dragging and dropping a .app file. If I change the appPackage and appActivity to be Google Messenger or something similar it works fine.
From the error, it appears that the appPackage and appActivity combination that you are supplying is not correct, most likely the appActivity is not the launch able one.
You can execute this command in the terminal/command prompt and make sure the app is getting launched. If it does, then it should work with Appium as well. If not, then you got to speak with your developer to figure out the correct app activity that needs to be used for launching the app through Appium.
adb shell am start -W -n com.MyApp.package/com.MyApp.package.MyApp.Activity -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000
Alternatively, you can avoid supplying appPackage and appActivity capabilities. Instead, supply "app" capability and provide the full path to the installable. With this approach, Appium will install the app, and it will try to fetch the appPackage and appActivity from the manifest.xml. It will then use this information to launch the app. Know that this may not work for all the apps. In that case, your only option is to figure out the correct appActivity as explained above.
You can read the official troubleshooting guide here. It has got your error covered. I'll urge you go through it: https://github.com/appium/appium/blob/1.x/docs/en/writing-running-appium/android/activity-startup.md#how-appium-starts-activities