-
-
Save sreereddymenon/74c2c23ec7e3392662943b875f73f8b1 to your computer and use it in GitHub Desktop.
gradle task to grant permission to device
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
android.applicationVariants.all { variant -> | |
def applicationId = variant.applicationId | |
def adb = androidadbExe. as String | |
def variantName = variant.name.capitalize() | |
def grantPermissionTask = task.create("create${variantName}Permissions") << { | |
"${adb} devices".execute().text.eachLine { | |
if(it.endsWith("device")){ | |
def device = it.split()[0] | |
println "Granting permissions on devices ${device}" | |
"${adb} -s ${devices} shell pm grant ${applicationId} android.permission.ACCESS_FINE_LOCATION".execute() | |
"${adb} -s ${devices} shell pm grant ${applicationId} android.permission.ACCESS_COARSE_LOCATION".execute() | |
"${adb} -s ${devices} shell pm grant ${applicationId} android.permission.READ_EXTERNAL_STORAGE".execute() | |
"${adb} -s ${devices} shell pm grant ${applicationId} android.permission.WRITE_EXTERNAL_STORAGE".execute() | |
} | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment