application requires INJECT_EVENTS permission

Mobile Testing, Android App Testing.
grekha
Posts: 7
Joined: Fri Jun 12, 2020 1:10 am

application requires INJECT_EVENTS permission

Post by grekha » Tue Jun 23, 2020 9:12 pm

Hi,

Ranorex isn't identifying the enter button of the app i'm testing and when running the scripts i see the error the following error.

Injecting to another application requires INJECT_EVENTS permission


Ranorex.Plugin.Mobile.XmlRpc.XmlRpcProtocolChannel.Call(MethodCall mc, TimeSpan responseTimeout)at Ranorex.Plugin.Mobile.Device.Channels.AppLogicChannel.Touch(String loc, Int32 elementIdentifier, Boolean isLongClick, Int32 duration)at Ranorex.Plugin.Mobile.Device.Channels.AppLogicChannel.Touch(IElementWithId element, TouchEvent evt)at Ranorex.Plugin.Mobile.RxIntegration.Elements.MobileFlavorElement.Touch(TouchEvent evt)at Ranorex.Touch.Tap(Element element, Int32 pointer, Location location, Duration touchDuration)at Ranorex.Adapter.Touch()at latest_solution.nextlogin.Ranorex.Core.Testing.ITestModule.Run() in c:\Users\reeee.re\Documents\Ranorex\RanorexStudio Projects\latest solution\latest solution\Login_again.cs:line 115at Ranorex.Core.Testing.TestModuleLeaf.RunInternal(DataContext parentDataContext, Int32 iteration, Int32 iterationCount, Boolean skipIteration)

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: application requires INJECT_EVENTS permission

Post by odklizec » Wed Jun 24, 2020 7:39 am

Hi,

Could you please tell us more about the tested app and what exactly you are trying to do? Ideally, post also the snapshot of the problematic element.

Also, I think you should see this post:
https://www.ranorex.com/forum/viewtopic ... NTS#p35252

Basically, if the element you are trying to access is a part of system process or another (non-instrumented) app, you can see this error. And there is unfortunately nothing you or Ranorex can do about this.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

mafi
Posts: 21
Joined: Thu Mar 21, 2019 2:43 pm

Re: application requires INJECT_EVENTS permission

Post by mafi » Fri Sep 22, 2023 9:53 am

I have the same issue. I opened a case at Ranorex on February 2023, but still no fix.
I suppose it is an Android13 limitation, because using Android12 I didn't have the issue.
Basically any element of the instrumented app cannot be interacted cause of the following exception:

Code: Select all

Injecting input events requires the caller (or the source of the instrumentation, if any) to have the INJECT_EVENTS permission. 
Show/Hide Stacktrace
in Ranorex.Plugin.Mobile.XmlRpc.XmlRpcProtocolChannel.Call(MethodCall mc, TimeSpan responseTimeout)in Ranorex.Plugin.Mobile.Device.Channels.AppLogicChannel.TouchChild(IElementWithId element, IChildElementWithId childElement, Boolean isLongTouch, TouchEvent evt)in Ranorex.Plugin.Mobile.RxIntegration.Elements.MobileWebFlavorElement.ClickDomElement(DomFlavorElement domElement, TouchEvent te)in Ranorex.Plugin.Mobile.RxIntegration.Elements.Web.DomFlavorElement.Touch(TouchEvent evt)in Ranorex.Touch.Tap(Element element, Int32 pointer, Location location, Duration touchDuration)in Ranorex.Adapter.Touch()in CommonCode.Custom.SetupTeardown.mMOT.mMOT_Android.Login_APK.Ranorex.Core.Testing.ITestModule.Run() in C:\Develop\Git\AUT-MonoMOT\MonoMOT\CommonCode\Custom\SetupTeardown\mMOT\mMOT_Android\Login_APK.cs:riga 158in Ranorex.Core.Testing.TestModuleLeaf.RunInternal(DataContext parentDataContext, Int32 iteration, Int32 iterationCount, Boolean skipIteration
If I try to access to the device shell and try to use the command input tap x y, I can tap the wanted button. So I think it is not a instrumented app limitation...

Julie.Toussaint
Posts: 15
Joined: Wed Feb 08, 2023 10:47 am

Re: application requires INJECT_EVENTS permission

Post by Julie.Toussaint » Fri Oct 27, 2023 12:42 pm

This issue is reoccurring on a mobile endpoint using Android 11 when attempting to Touch() on an object that was found by Ranorex.

- The apk was correctly instrumented using the Ranorex wizard.
- Keyboard action work just fine, a Touch action does not.
- This error only occurs roughly 80% of the time

Another forum post describing this issue from 2015!, unresolved.
Previous forum post describing this issue from 2019!, unresolved.
This forum post was made in 2020, it is now 2023 and this has yet to be resolved...

Am still attempting to provide a workaround :?
Application Engineer 🇧🇪
The workaround experience, awaiting a reply

Julie.Toussaint
Posts: 15
Joined: Wed Feb 08, 2023 10:47 am

Re: application requires INJECT_EVENTS permission

Post by Julie.Toussaint » Mon Nov 20, 2023 10:05 am

odklizec wrote:
Wed Jun 24, 2020 7:39 am
Hi,

Could you please tell us more about the tested app and what exactly you are trying to do? Ideally, post also the snapshot of the problematic element.

Also, I think you should see this post:
https://www.ranorex.com/forum/viewtopic ... NTS#p35252

Basically, if the element you are trying to access is a part of system process or another (non-instrumented) app, you can see this error. And there is unfortunately nothing you or Ranorex can do about this.
Would you kindly reply as to resolve this issue so we can continue supporting Ranorex-driven automated tests on mobile devices?
It seems improbable that there is no way to fix this issue as no problems occurred before when we created several test suites containing test cases using another version of Android.
(Installing the application as a system app is not an option for our device, as suggested when googling this problem.)
Application Engineer 🇧🇪
The workaround experience, awaiting a reply