Can't click Allow button in permission dialog in Android using Appium

Use full resource ID ...It worked for me....

below line worked for me.... driver.findElement(MobileBy.id("com.android.packageinstaller:id/permission_allow_button")).click();


With the below snippet I am able to click on all the allow buttons to get the permissions.

while (driver.findElements(MobileBy.xpath("//*[@class='android.widget.Button'][2]")).size()>0) {
    driver.findElement(MobileBy.xpath("//*[@class='android.widget.Button'][2]")).click();
}

Starting from appium 1.6.3 you can just add:

capabilities.setCapability("autoGrantPermissions", "true");

And you'll always allow all permissions your app wants.