testing-samples
testing-samples copied to clipboard
Grant Permissions Rule errors out while connecting to UiAutomation
I keep getting these errors for few of my automation tests. Most of the times, on re-running the tests, it works fine again
java.lang.RuntimeException: Error while connecting UiAutomation
at android.app.UiAutomation.connect(UiAutomation.java:239)
at android.app.Instrumentation.getUiAutomation(Instrumentation.java:2045)
at android.app.Instrumentation.getUiAutomation(Instrumentation.java:2002)
at androidx.test.runner.permission.UiAutomationShellCommand.<init>(UiAutomationShellCommand.java:65)
at androidx.test.runner.permission.PermissionRequester.addPermissions(PermissionRequester.java:92)
at androidx.test.rule.GrantPermissionRule.grantPermissions(GrantPermissionRule.java:100)
at androidx.test.rule.GrantPermissionRule.grant(GrantPermissionRule.java:94)
at com.example.package.tests.BaseTest.<init>(BaseTest.java:40)
at com.example.package.tests.ReportFragmentTest.<init>(ReportFragmentTest.java:22)
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:334)
at org.junit.runners.BlockJUnit4ClassRunner.createTest(BlockJUnit4ClassRunner.java:217)
at org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall(BlockJUnit4ClassRunner.java:266)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at androidx.test.runner.AndroidJUnit4.run(AndroidJUnit4.java:104)
I am granting permissions in the following manner
public GrantPermissionRule grantPermissionRule = GrantPermissionRule.grant(Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_PHONE_STATE, Manifest.permission.READ_EXTERNAL_STORAGE);
Any help in this regards will be appreciated.
did you got any solution for the above problem ?