Permission to start activity denied while launching the app

Hello,

When I run the test sometime it works fine but sometime it fails and gives the followsing error.

A new session could not be created. (Original error: Permission to start activity denied.)

Appium server log is as follows:

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}

Could anyone please tell me the reason for this?

In the android manifest, in the activity you wish to open, add android:exported=“true” and it should work out just fine.
Also, be sure that in settings->DeveloperOptions the device is in debug mode.

Give me a feedback if this doesn’t work please.

2 Likes

Just adding a note that this helped me. Thanks @phillippe

1 Like

The manifest permission android:exported=“true” might not be available in the distributed builds. Does that mean we are restricted to test builds only (where we need access to source code modifications)

Two days of search all over the web and this post solved the issue - thanks Philippe_Pageau

what if this error occurs when i just have an apk file and i want to automate the app because clearly i cannot access the manifest of an apk

How about using apktool to decompile the APK, changing the AndroidManifest as needed, and then repacking and resigning the modified APK contents?

ok i can try that but are you sure that there is no other way… i mean i have configured Appium before in one of my projects and i dont remember changing any permissions in manifest. Still i would give ur suggestion a try. Is there any other way?

Okay, let me try to straighten out the story here. You’re right by pointing out that the AndroidManifest shouldn’t be changed for Appium automation, so we need to start asking why we need to change it in the first place.

We want to change the manifest to launch a particular activity because the activity is forbidden from being launched by an external intent. This suggests the activity is not a launcher activity. Why are we trying to launch a non-launcher activity?

HI Philippe_Pageau ,

I am beginner to appium . i have written the code to test some cases in hybrid_app. i.e "amazon kindle " app. I have run the same code on both emulator and as well as the mobile(Real) Device . It is working fine with the emulator . But i am facing the below error while running on the real device .

kindly help me out . I have been struggling to find out the reason and to make it work on real device from Past 1 week .

Emulator Logs :slight_smile:

Launching Appium server with command: C:\Program Files (x86)\Appium\node.exe lib\server\main.js --address 127.0.0.1 --port 4723 --platform-name Android --platform-version 21 --automation-name Appium --log-no-color
info: Welcome to Appium v1.4.16 (REV ae6877eff263066b26328d457bd285c0cc62430d)
info: Appium REST http interface listener started on 127.0.0.1:4723
info: [debug] Non-default server args: {“address”:“127.0.0.1”,“logNoColors”:true,“platformName”:“Android”,“platformVersion”:“21”,“automationName”:“Appium”}
info: Console LogLevel: debug
info: → POST /wd/hub/session {“desiredCapabilities”:{“platform”:“ANDROID”,“disableAndroidWatchers”:false,“platformName”:“Android”,“deviceName”:“Android Emulator”,“browserName”:“”,“appActivity”:“com.amazon.kcp.library.StandaloneLibraryActivity”,“androidDeviceReadyTimeout”:30,“deviceReadyTimeout”:30,“appPackage”:“com.amazon.kindle”,“version”:“5.0.1”}}
info: Client User-Agent string: Apache-HttpClient/4.5.2 (Java/1.7.0_79)
info: [debug] The following desired capabilities were provided, but not recognized by appium. They will be passed on to any other services running on this server. : platform, androidDeviceReadyTimeout, version
info: [debug] Didn’t get app but did get Android package, will attempt to launch it on the device
info: [debug] Creating new appium session d58686c1-3a74-48d7-953d-3d71b21b7914
info: Starting android appium
info: [debug] Getting Java version
info: Java version is: 1.7.0_79
info: [debug] Checking whether adb is present
info: [debug] Using adb from E:\AppiumSetup\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe
warn: No app capability, can’t parse package/activity
info: [debug] Using fast reset? true
info: [debug] Preparing device for session
info: [debug] Not checking whether app is present since we are assuming it’s already on the device
info: Retrieving device
info: [debug] Trying to find a connected android device
info: [debug] Getting connected devices…
info: [debug] executing cmd: E:\AppiumSetup\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe devices
info: [debug] 1 device(s) connected
info: Found device 192.168.4.101:5555
info: [debug] Setting device id to 192.168.4.101:5555
info: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 30)
info: [debug] executing cmd: E:\AppiumSetup\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -s 192.168.4.101:5555 wait-for-device
info: [debug] executing cmd: E:\AppiumSetup\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -s 192.168.4.101:5555 shell “echo ‘ready’”
info: [debug] Starting logcat capture
info: [debug] Getting device API level
info: [debug] executing cmd: E:\AppiumSetup\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -s 192.168.4.101:5555 shell “getprop ro.build.version.sdk”
info: [debug] Device is at API Level 21
info: Device API level is: 21
info: [debug] Extracting strings for language: default
info: [debug] Apk doesn’t exist locally
info: [debug] Could not get strings, but it looks like we had an old strings file anyway, so ignoring
info: [debug] executing cmd: E:\AppiumSetup\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -s 192.168.4.101:5555 shell “rm -rf /data/local/tmp/strings.json”
info: [debug] Not uninstalling app since server not started with --full-reset
info: [debug] Skipping install since we launched with a package instead of an app path
info: [debug] Forwarding system:4724 to device:4724
info: [debug] executing cmd: E:\AppiumSetup\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -s 192.168.4.101:5555 forward tcp:4724 tcp:4724
info: [debug] Pushing appium bootstrap to device…
info: [debug] executing cmd: E:\AppiumSetup\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -s 192.168.4.101:5555 push “C:\Program Files (x86)\Appium\node_modules\appium\build\android_bootstrap\AppiumBootstrap.jar” /data/local/tmp/
info: [debug] Pushing settings apk to device…
info: [debug] executing cmd: E:\AppiumSetup\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -s 192.168.4.101:5555 install “C:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk”
info: [debug] Pushing unlock helper app to device…
info: [debug] executing cmd: E:\AppiumSetup\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -s 192.168.4.101:5555 install “C:\Program Files (x86)\Appium\node_modules\appium\build\unlock_apk\unlock_apk-debug.apk”
info: Starting App
info: [debug] Attempting to kill all ‘uiautomator’ processes
info: [debug] Getting all processes with ‘uiautomator’
info: [debug] executing cmd: E:\AppiumSetup\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -s 192.168.4.101:5555 shell “ps ‘uiautomator’”
info: [debug] No matching processes found
info: [debug] Running bootstrap
info: [debug] spawning: E:\AppiumSetup\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -s 192.168.4.101:5555 shell uiautomator runtest AppiumBootstrap.jar -c io.appium.android.bootstrap.Bootstrap -e pkg com.amazon.kindle -e disableAndroidWatchers false
info: [debug] [UIAUTOMATOR STDOUT] WARNING: linker:
info: [debug] [UIAUTOMATOR STDOUT] libhoudini.so has text relocations. This is wasting memory and prevents security hardening. Please fix.
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: numtests=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=
info: [debug] [UIAUTOMATOR STDOUT] io.appium.android.bootstrap.Bootstrap:
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: current=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: 1
info: [debug] [BOOTSTRAP] [debug] Socket opened on port 4724
info: [debug] [BOOTSTRAP] [debug] Appium Socket Server Ready
info: [debug] [BOOTSTRAP] [debug] Loading json…
info: [debug] [BOOTSTRAP] [debug] Registered crash watchers.
info: [debug] Waking up device if it’s not alive
info: [debug] Pushing command to appium work queue: [“wake”,{}]
info: [debug] [BOOTSTRAP] [debug] Client connected
info: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“action”,“action”:“wake”,“params”:{}}
info: [debug] executing cmd: E:\AppiumSetup\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -s 192.168.4.101:5555 shell “dumpsys window”
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: wake
info: [debug] [BOOTSTRAP] [debug] Returning result: {“status”:0,“value”:true}
info: [debug] Screen already unlocked, continuing.
info: [debug] Pushing command to appium work queue: [“getDataDir”,{}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“action”,“action”:“getDataDir”,“params”:{}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: getDataDir
info: [debug] [BOOTSTRAP] [debug] Returning result: {“status”:0,“value”:“/data”}
info: [debug] dataDir set to: /data
info: [debug] Pushing command to appium work queue: [“compressedLayoutHierarchy”,{“compressLayout”:false}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“action”,“action”:“compressedLayoutHierarchy”,“params”:{“compressLayout”:false}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: compressedLayoutHierarchy
info: [debug] [BOOTSTRAP] [debug] Returning result: {“status”:0,“value”:false}
info: [debug] Getting device API level
info: [debug] executing cmd: E:\AppiumSetup\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -s 192.168.4.101:5555 shell “getprop ro.build.version.sdk”
info: [debug] Device is at API Level 21
info: [debug] executing cmd: E:\AppiumSetup\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -s 192.168.4.101:5555 shell “am start -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000 -n com.amazon.kindle/com.amazon.kcp.library.StandaloneLibraryActivity”
info: [debug] Waiting for pkg “com.amazon.kindle” and activity “com.amazon.kcp.library.StandaloneLibraryActivity” to be focused
info: [debug] Getting focused package and activity
info: [debug] executing cmd: E:\AppiumSetup\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -s 192.168.4.101:5555 shell “dumpsys window windows”
info: [debug] executing cmd: E:\AppiumSetup\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -s 192.168.4.101:5555 shell “getprop ro.build.version.release”
info: [debug] Device is at release version 5.0
info: [debug] Device launched! Ready for commands
info: [debug] Setting command timeout to the default of 60 secs
info: [debug] Appium session started with sessionId d58686c1-3a74-48d7-953d-3d71b21b7914
info: ← POST /wd/hub/session 303 10663.732 ms - 74
info: → GET /wd/hub/session/d58686c1-3a74-48d7-953d-3d71b21b7914 {}
info: [debug] Responding to client with success: {“status”:0,“value”:{“platform”:“ANDROID”,“browserName”:“”,“platformVersion”:“5.0”,“webStorageEnabled”:false,“takesScreenshot”:true,“javascriptEnabled”:true,“databaseEnabled”:false,“networkConnectionEnabled”:true,“locationContextEnabled”:false,“warnings”:{},“desired”:{“platform”:“ANDROID”,“disableAndroidWatchers”:false,“platformName”:“Android”,“deviceName”:“Android Emulator”,“browserName”:“”,“appActivity”:“com.amazon.kcp.library.StandaloneLibraryActivity”,“androidDeviceReadyTimeout”:30,“deviceReadyTimeout”:30,“appPackage”:“com.amazon.kindle”,“version”:“5.0.1”},“disableAndroidWatchers”:false,“platformName”:“Android”,“deviceName”:“192.168.4.101:5555”,“appActivity”:“com.amazon.kcp.library.StandaloneLibraryActivity”,“androidDeviceReadyTimeout”:30,“deviceReadyTimeout”:30,“appPackage”:“com.amazon.kindle”,“version”:“5.0.1”},“sessionId”:“d58686c1-3a74-48d7-953d-3d71b21b7914”}
info: ← GET /wd/hub/session/d58686c1-3a74-48d7-953d-3d71b21b7914 200 10.419 ms - 880 {“status”:0,“value”:{“platform”:“ANDROID”,“browserName”:“”,“platformVersion”:“5.0”,“webStorageEnabled”:false,“takesScreenshot”:true,“javascriptEnabled”:true,“databaseEnabled”:false,“networkConnectionEnabled”:true,“locationContextEnabled”:false,“warnings”:{},“desired”:{“platform”:“ANDROID”,“disableAndroidWatchers”:false,“platformName”:“Android”,“deviceName”:“Android Emulator”,“browserName”:“”,“appActivity”:“com.amazon.kcp.library.StandaloneLibraryActivity”,“androidDeviceReadyTimeout”:30,“deviceReadyTimeout”:30,“appPackage”:“com.amazon.kindle”,“version”:“5.0.1”},“disableAndroidWatchers”:false,“platformName”:“Android”,“deviceName”:“192.168.4.101:5555”,“appActivity”:“com.amazon.kcp.library.StandaloneLibraryActivity”,“androidDeviceReadyTimeout”:30,“deviceReadyTimeout”:30,“appPackage”:“com.amazon.kindle”,“version”:“5.0.1”},“sessionId”:“d58686c1-3a74-48d7-953d-3d71b21b7914”}
info: → GET /wd/hub/session/d58686c1-3a74-48d7-953d-3d71b21b7914/contexts {}
info: [debug] Getting a list of available webviews
info: [debug] executing cmd: E:\AppiumSetup\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -s 192.168.4.101:5555 shell “cat /proc/net/unix”
info: [debug] Available contexts:
info: [debug]
info: [debug] Available contexts: NATIVE_APP
info: [debug] Responding to client with success:

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Error logs when ran in Mobile Device :slight_smile:

Launching Appium server with command: C:\Program Files (x86)\Appium\node.exe lib\server\main.js --address 127.0.0.1 --port 4723 --platform-name Android --platform-version 21 --automation-name Appium --log-no-color
info: Welcome to Appium v1.4.16 (REV ae6877eff263066b26328d457bd285c0cc62430d)
info: Appium REST http interface listener started on 127.0.0.1:4723
info: [debug] Non-default server args: {“address”:“127.0.0.1”,“logNoColors”:true,“platformName”:“Android”,“platformVersion”:“21”,“automationName”:“Appium”}
info: Console LogLevel: debug
info: → POST /wd/hub/session {“desiredCapabilities”:{“platform”:“ANDROID”,“disableAndroidWatchers”:false,“platformName”:“Android”,“deviceName”:“Android”,“browserName”:“”,“appActivity”:“com.amazon.kcp.library.StandaloneLibraryActivity”,“androidDeviceReadyTimeout”:30,“deviceReadyTimeout”:30,“appPackage”:“com.amazon.kindle”,“version”:“5.0.1”}}
info: Client User-Agent string: Apache-HttpClient/4.5.2 (Java/1.7.0_79)
info: [debug] The following desired capabilities were provided, but not recognized by appium. They will be passed on to any other services running on this server. : platform, androidDeviceReadyTimeout, version
info: [debug] Didn’t get app but did get Android package, will attempt to launch it on the device
info: [debug] Creating new appium session dc4f83af-991f-4db2-9a55-668d88d87de9
info: Starting android appium
info: [debug] Getting Java version
info: Java version is: 1.7.0_79
info: [debug] Checking whether adb is present
info: [debug] Using adb from E:\AppiumSetup\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe
warn: No app capability, can’t parse package/activity
info: [debug] Using fast reset? true
info: [debug] Preparing device for session
info: [debug] Not checking whether app is present since we are assuming it’s already on the device
info: Retrieving device
info: [debug] Trying to find a connected android device
info: [debug] Getting connected devices…
info: [debug] executing cmd: E:\AppiumSetup\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe devices
info: [debug] 1 device(s) connected
info: Found device F8AZCY09D179
info: [debug] Setting device id to F8AZCY09D179
info: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 30)
info: [debug] executing cmd: E:\AppiumSetup\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -s F8AZCY09D179 wait-for-device
info: [debug] executing cmd: E:\AppiumSetup\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -s F8AZCY09D179 shell “echo ‘ready’”
info: [debug] Starting logcat capture
info: [debug] Getting device API level
info: [debug] executing cmd: E:\AppiumSetup\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -s F8AZCY09D179 shell “getprop ro.build.version.sdk”
info: [debug] Device is at API Level 21
info: Device API level is: 21
info: [debug] Extracting strings for language: default
info: [debug] Apk doesn’t exist locally
info: [debug] Could not get strings, but it looks like we had an old strings file anyway, so ignoring
info: [debug] executing cmd: E:\AppiumSetup\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -s F8AZCY09D179 shell “rm -rf /data/local/tmp/strings.json”
info: [debug] Not uninstalling app since server not started with --full-reset
info: [debug] Skipping install since we launched with a package instead of an app path
info: [debug] Forwarding system:4724 to device:4724
info: [debug] executing cmd: E:\AppiumSetup\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -s F8AZCY09D179 forward tcp:4724 tcp:4724
info: [debug] Pushing appium bootstrap to device…
info: [debug] executing cmd: E:\AppiumSetup\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -s F8AZCY09D179 push “C:\Program Files (x86)\Appium\node_modules\appium\build\android_bootstrap\AppiumBootstrap.jar” /data/local/tmp/
info: [debug] Pushing settings apk to device…
info: [debug] executing cmd: E:\AppiumSetup\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -s F8AZCY09D179 install “C:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk”
info: [debug] Pushing unlock helper app to device…
info: [debug] executing cmd: E:\AppiumSetup\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -s F8AZCY09D179 install “C:\Program Files (x86)\Appium\node_modules\appium\build\unlock_apk\unlock_apk-debug.apk”
info: Starting App
info: [debug] Attempting to kill all ‘uiautomator’ processes
info: [debug] Getting all processes with ‘uiautomator’
info: [debug] executing cmd: E:\AppiumSetup\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -s F8AZCY09D179 shell “ps ‘uiautomator’”
info: [debug] No matching processes found
info: [debug] Running bootstrap
info: [debug] spawning: E:\AppiumSetup\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -s F8AZCY09D179 shell uiautomator runtest AppiumBootstrap.jar -c io.appium.android.bootstrap.Bootstrap -e pkg com.amazon.kindle -e disableAndroidWatchers false
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: numtests=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=
info: [debug] [UIAUTOMATOR STDOUT] io.appium.android.bootstrap.Bootstrap:
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: current=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: 1
info: [debug] [BOOTSTRAP] [debug] Socket opened on port 4724
info: [debug] [BOOTSTRAP] [debug] Appium Socket Server Ready
info: [debug] [BOOTSTRAP] [debug] Loading json…
info: [debug] [BOOTSTRAP] [debug] Registered crash watchers.
info: [debug] Waking up device if it’s not alive
info: [debug] Pushing command to appium work queue: [“wake”,{}]
info: [debug] [BOOTSTRAP] [debug] Client connected
info: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“action”,“action”:“wake”,“params”:{}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: wake
info: [debug] [BOOTSTRAP] [debug] Returning result: {“status”:0,“value”:true}
info: [debug] executing cmd: E:\AppiumSetup\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -s F8AZCY09D179 shell “dumpsys window”
info: [debug] Screen already unlocked, continuing.
info: [debug] Pushing command to appium work queue: [“getDataDir”,{}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“action”,“action”:“getDataDir”,“params”:{}}
info: [debug] dataDir set to: /data/local/tmp
info: [debug] Pushing command to appium work queue: [“compressedLayoutHierarchy”,{“compressLayout”:false}]
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: getDataDir
info: [debug] [BOOTSTRAP] [debug] Returning result: {“status”:0,“value”:“/data/local/tmp”}
info: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“action”,“action”:“compressedLayoutHierarchy”,“params”:{“compressLayout”:false}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: compressedLayoutHierarchy
info: [debug] [BOOTSTRAP] [debug] Returning result: {“status”:0,“value”:false}
info: [debug] Getting device API level
info: [debug] executing cmd: E:\AppiumSetup\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -s F8AZCY09D179 shell “getprop ro.build.version.sdk”
info: [debug] Device is at API Level 21
info: [debug] executing cmd: E:\AppiumSetup\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -s F8AZCY09D179 shell “am start -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000 -n com.amazon.kindle/com.amazon.kcp.library.StandaloneLibraryActivity”
error: Permission to start activity denied.
info: [debug] Stopping logcat capture
info: [debug] Logcat terminated with code null, signal SIGTERM
info: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“shutdown”}
info: [debug] Sent shutdown command, waiting for UiAutomator to stop…
info: [debug] [BOOTSTRAP] [debug] Got command of type SHUTDOWN
info: [debug] [BOOTSTRAP] [debug] Returning result: {“status”:0,“value”:“OK, shutting down”}
info: [debug] [BOOTSTRAP] [debug] Closed client connection
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: numtests=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=.
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: current=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: 0
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=
info: [debug] [UIAUTOMATOR STDOUT] Test results for WatcherResultPrinter=.
info: [debug] [UIAUTOMATOR STDOUT] Time: 1.298
info: [debug] [UIAUTOMATOR STDOUT] OK (1 test)
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: -1
info: [debug] UiAutomator shut down normally
info: [debug] Cleaning up android objects
info: [debug] Cleaning up appium session
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 19359.780 ms - 194
error: Failed to start an Appium session, err was: Error: Permission to start activity denied.

-------------------------------------------------------------------------------------------------------------------------------------------------------------------Tried to invoke the app with the package and activity from “CMD” also but faced below error :slight_smile:

Starting: Intent { cmp=com.amazon.kindle/com.amazon.kcp.library.StandaloneLibraryActivity }
java.lang.SecurityException: Permission Denial: starting Intent { flg=0x10000000 cmp=com.amazon.kindle/com.amazon.kcp.library.StandaloneLibraryActivity } from null (p
id=12523, uid=2000) not exported from uid 10167
at android.os.Parcel.readException(Parcel.java:1540)
at android.os.Parcel.readException(Parcel.java:1493)
at android.app.ActivityManagerProxy.startActivityAsUser(ActivityManagerNative.java:2479)
at com.android.commands.am.Am.runStart(Am.java:740)
at com.android.commands.am.Am.onRun(Am.java:304)
at com.android.internal.os.BaseCommand.run(BaseCommand.java:47)
at com.android.commands.am.Am.main(Am.java:99)
at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:250)


Run in command line:

adb shell am start -n your.package.name/your.activity.Name

if it is not possible, then appium wont be able also and normal user wont launch that activity also from outside of the app.

1 Like

Can you please tell us how to set
add android:exported=“true”
Did I need to set this as an capability

I am getting the same issue for the past few weeks
My code is like this
WebDriver driver;
@Test
public void SetUpForApk() throws MalformedURLException{
File f = new File(“C:\StandAloneAndroid\build-tools\25.0.3”);
File fs = new File(f,“app-dev-debug.apk”);
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(MobileCapabilityType.PLATFORM_NAME, “Android”);
cap.setCapability(MobileCapabilityType.PLATFORM_VERSION, “6.0”);
cap.setCapability(MobileCapabilityType.DEVICE_NAME, “28A4AA040IG4012”);
cap.setCapability(MobileCapabilityType.APP, fs.getAbsolutePath());
cap.setCapability(“autoGrantPermissions”,“true”);
cap.setCapability(“appPackage”, “com.edmobilelabs.sling.dev”);
cap.setCapability(“appActivity”, “com.edmobilelabs.sling.ui.ScrWalkThrough”);
driver = new RemoteWebDriver(new URL(“http://127.0.0.1:4723/wd/hub”), cap);

Hi Telmo,
I have used your command and its showing security exception
Can you please tell me how to solve this issue

Waiting eagerly for your reply

That activity is not authorized to be called externally

Your dev team would need to set android:exported=“true” in AndroidManifest.xml file

Thanks for the reply

Can you please tell me where to include that line of code in the Manifest file?
Because i have the code from dev team…

set for atleast 6 imp capabilities
cap.setCapability(MobileCapabilityType.PLATFORM_NAME, “Android”);
cap.setCapability(MobileCapabilityType.PLATFORM_VERSION, “6.0.1”);
cap.setCapability(MobileCapabilityType.DEVICE_NAME, “45*********0”);
cap.setCapability(“appPackage”, “com.e**v");
cap.setCapability(“appActivity”, "com.e
”);
driver = new AndroidDriver(new URL(“http://127.0.0.1:4723/wd/hub”), cap);

use selenium server StandAloneJar and appium 1.6.4
ur problem might get solved
As there are lot of compatability Issue

Pass the main activity name to desired capabilities of your app. you can get or spy the main activity of your app by using hierarchy viewer in SDK folder.

This error will come when you are giving unauthorized activity.

You can also get to know all information on appium log which activity you need to launch. For more information, you can also watch this https://www.youtube.com/playlist?list=PLXbcghgSZDroz9nez1IrbL2hnMVJ0ba1W

Hi,

I am able to launch the activity using the adb command, however things are not working when I am using same in appium,

Appium server version: v1.7.2

Below is my code

  def setUp(self):
        "Setup for the test"
        desired_caps = {}
        desired_caps['platformName'] = 'Android'
        desired_caps['platformVersion'] = '6.0.1'
        desired_caps['deviceName'] = 'LYF WIND7i'
        # Since the app is already installed launching it using package and activity name
        desired_caps['appPackage'] = ' com.google.android.gm'
        desired_caps['appActivity'] = 'com.google.android.gm.welcome.WelcomeTourActivity'
        self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)

And below is the error I am getting while executing it

[ADB] 1 device(s) connected
[ADB] Running ‘C:\Users\roshni\AppData\Local\Android\sdk\platform-tools\adb.exe’ with args: [“-P”,5037,“-s”,“38f7da6d”,“shell”,“am”,“force-stop”,“io.appium.unlock”]
[AndroidDriver] Not cleaning generated files. Add clearSystemFiles capability if wanted.
[MJSONWP] Encountered internal error running command: Error: Error occured while starting App. Original error: Permission to start activity denied.
at Object.wrappedLogger.errorAndThrow (C:\Users\roshni\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\appium-support\lib\logging.js:69:13)
at ADB.callee$0$0$ (C:\Users\roshni\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\appium-adb\lib\tools\apk-utils.js:101:9)
at tryCatch (C:\Users\roshni\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40)
at GeneratorFunctionPrototype.invoke [as _invoke] (C:\Users\roshni\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:315:22)
at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (C:\Users\roshni\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:100:21)
at GeneratorFunctionPrototype.invoke (C:\Users\roshni\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37)