When running appium test on android real device getting error: Permission to start activity denied


#1

Hi,

I am trying to run mobile app in android real device. I have connected the device through USB Debugging. When I run “adb devices” from command prompt device is display as attached devices. My phone’s android version is 4.2.2. When i run the test as testng test nothing happens.

Please help me. Thank you in advance.

These are my appium logs.

error: Failed to start an Appium session, err was: Error: Permission to start activity denied.
info: [debug] Error: Permission to start activity denied.
at [object Object]. (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:1151:19)
at [object Object]. (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:180:9)
at ChildProcess.exithandler (child_process.js:742:7)
at ChildProcess.emit (events.js:110:17)
at maybeClose (child_process.js:1016:16)
at Process.ChildProcess._handle.onexit (child_process.js:1088:5)
info: [debug] Responding to client with error: {“status”:33,“value”:{“message”:“A new session could not be created. (Original error: Permission to start activity denied.)”,“origValue”:“Permission to start activity denied.”},“sessionId”:null}
info: <-- POST /wd/hub/session 500 16823.068 ms - 194


#2

enable Development mode on phone.


#3

Hi,

I did enable the developer options and also enable USB Debugging.


#4

and when connected phone to computer Accepted Allow connect to this PC dialog?

and disable in Development “Check Harmfull Behavior over USB…” - this cause also problem with some phones


#5

Yes. I have accepted Allow connect to this PC


#6

and check - https://github.com/appium/appium/issues/4607


#7

Still doesn’t work for me, but thanks though.


#8

try another device :slight_smile: and better use android 4.3+ as far as with 4.2 findBy.id does not work.


#9

Can you try running the command to start the activity yourself? It should be of the form:

adb shell am start -n application_id/activity_name

Example:

adb shell am start -n com.example.appium/com.example.appium.MainActivity

Perhaps running the command manually might reveal a more interesting error message to solve your problem. :slight_smile:


#10

Hi,

I solved my problem with running tests on real device. In the code I have given appActivity as Login Activity. But before that app has Splash Screen activity. So I changed the appActivity as Splash Screen and it worked.

Thanks all for your replies. They helped me to gain knowledge. Thanks.


#11

Sachi Thanks it solved my problem as well .


#12

Can U please tell me… how u done this?