I have 3 flavors and each of them should have a different permissions. My flavors are defined like so:
allPermissions {
dimension "permissions"
manifestPlaceholders = [excludeCallLogPermission: "false", excludeSmsPermission: "false"]
}
noSmsPermission {
dimension "permissions"
manifestPlaceholders = [excludeSmsPermission: "true"]
}
noSmsNoCallogPermission {
dimension "permissions"
manifestPlaceholders = [excludeCallLogPermission: "true", excludeSmsPermission: "true"]
}
and in my Manifest I have this:
<uses-permission android:name="android.permission.READ_CALL_LOG"
tools:remove="${excludeCallLogPermission}"/>
<uses-permission android:name="android.permission.SEND_SMS"
tools:remove="${excludeSmsPermission}"/>enter code here
It doesnt give any errors and builds but the app has the 2 mentioned permissions even if the flavor sets both to false so it is not working.
If I try using tools:node="${excludeSmsPermission}" and set the value of it to remove I get this warning
Found a hackish solution that works
allPermissions {
dimension "permissions"
manifestPlaceholders = [extraPermission1: "android.permission.SEND_SMS", extraPermission2: "android.permission.READ_CALL_LOG"]
}
noSmsPermission {
dimension "permissions"
manifestPlaceholders = [extraPermission1: "android.permission.placeholder", extraPermission2: "android.permission.READ_CALL_LOG"]
}
noSmsNoCallogPermission {
dimension "permissions"
manifestPlaceholders = [extraPermission1: "android.permission.placeholder", extraPermission2: "android.permission.placeholder"]
}
and
<uses-permission android:name="${extraPermission1}"/>
<uses-permission android:name="${extraPermission2}"/>