Bug 40303 - no way to define, override or configure "resConfigs"
Summary: no way to define, override or configure "resConfigs"
Alias: None
Product: Android
Classification: Xamarin
Component: MSBuild ()
Version: 6.0.99
Hardware: All All
: Normal normal
Target Milestone: ---
Assignee: dean.ellis
URL: http://flagbug.com/2016/01/16/removin...
Depends on:
Reported: 2016-04-12 12:49 UTC by Geoffrey Huntley
Modified: 2017-11-02 15:35 UTC (History)
3 users (show)

Tags: ac
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report for Bug 40303 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:

Description Geoffrey Huntley 2016-04-12 12:49:12 UTC

If you're developing an Android app and add the Google Play Services or Android Support Library to you're app, you're probably suddenly seeing an enormous increase in supported languages when uploading the app to Google Play.
This happens, because those libraries ship with built-in multi-language support and Google Play has no way of knowing that those additional language files aren't coming from your app itself.

If you're developing with Java and Gradle, the solution is simple, just add this to your build.gradle file:

defaultConfig {
  minSdkVersion 15
  targetSdkVersion 22
  versionCode 75
  versionName "1.0.0"

  resConfigs "en", "de" <--

This way only German and English resources are included in your final APK.

If you're developing with Xamarin for Android, you're out of luck, there isn't a built-in way to do this.

- Manually decompile APK, remove languages needed, recompile APK (yick)

Reference Material:
- http://flagbug.com/2016/01/16/removing-unused-language-resource-from-android-apk-xamarin/
- https://forums.xamarin.com/discussion/32159/xamarin-android-support-v7-appcompat-adds-many-languages-to-final-apk
- https://stackoverflow.com/questions/32247124/how-do-i-remove-unused-languages-from-the-final-apk-file-with-xamarin-android/34787251#34787251
Comment 1 Prashant [MSFT] 2017-06-28 10:57:36 UTC
Sample application


Follow the instructions from this SO post[1] to see the generated Strings.xml for different languages

1. https://stackoverflow.com/questions/32247124/how-do-i-remove-unused-languages-from-the-final-apk-file-with-xamarin-android/34787251#34787251
Comment 2 Boris Spinner 2017-11-02 14:40:02 UTC
This problem is not limited to release builds only.
Limiting `resConfigs` to specific configurations is a recommended way to speed up build times.

see https://developer.android.com/studio/build/optimize-your-build.html
Comment 3 Boris Spinner 2017-11-02 14:41:21 UTC
* to speed up development/testing build times
Comment 4 Boris Spinner 2017-11-02 15:35:52 UTC
"No way" is actually not true.
You can provide "AndroidResgenExtraArgs" in your project file and add "-c en,de" etc.

See aapt documentation:

-c  specify which configurations to include.  The default is all
       configurations.  The value of the parameter should be a comma
       separated list of configuration values.  Locales should be specified
       as either a language or language-region pair.  Some examples: