I have set up Gradle to add package name suffix to my debug app so I could have release version that I\'m using and debug version on one phone. I was referencing this: http:
Based on the sample by @ChristianMelchior, here's my solution, which fixes two issues in the previous solutions:
solutions that change values.xml in the build directory cause a full rebuild of resources (including aapt of all drawables)
for an unknown reason, IntelliJ (and probably Android Studio) do not reliably process the resources, causing the build to contain un-replaced .res-auto provider authorities
This new solution does things more the Gradle way by creating a new task and allows for incremental builds by defining input and output files.
create a file (in the example I put it in a variants directory), formatted like a resource xml file, which contains string resources. These will be merged into the app's resources, and any occurrence of .res-auto in the values will be replaced with the variant's package name, for example
add the build_extras.gradle file from this gist to your project and reference it from the main build.gradle by adding apply from: './build_extras.gradle' somewhere above the android block
make sure you set a default package name by adding it to the android.defaultConfig block of build.gradle
in AndroidManifest.xml and other configuration files (such as xml/searchable.xml for auto-completion search providers), reference the provider (for example @string/search_provider)
if you need to get the same name, you can use the BuildConfig.PACKAGE_NAME variable, for example BuildConfig.PACKAGE_NAME + ".MySearchProvider"
https://gist.github.com/paour/9189462