Android Studio exports strings from support library to APK-ThrowExceptions

Exception or error:

Recently i switched from Eclipse to Android Studio. I have a project with multiple module dependencies. One dependency is the support library appcompat, included like this:

dependencies {
    compile "com.android.support:appcompat-v7:19+"
}

In the Android docs i found out that this library needs to be imported with resources, which seem to work OK. I use the library in my project without problems.

The problem is, when i build an APK and run aapt, the outpus says:

locales: '--_--' 'de' 'nl' 'pl' 'sl' 'fr' 'cs' 'es' 'it' 'ca' 'da' 'fa' 'ja' 'nb' 'af' 
'bg' 'th' 'fi' 'hi' 'vi' 'sk' 'uk' 'el' 'tl' 'am' 'in' 'ko' 'ro' 'ar' 'hr' 'sr' 'tr' 
'lt' 'pt' 'hu' 'ru' 'zu' 'lv' 'sv' 'iw' 'sw' 'fr_CA' 'lo_LA' 'en_GB' 'et_EE' 'ka_GE' 
'km_KH' 'zh_HK' 'hy_AM' 'zh_CN' 'en_IN' 'mn_MN' 'es_US' 'pt_PT' 'zh_TW' 'ms_MY'

But this is not true, my app supports only the first 8 listed languages. When i upload this apk to Play, it’s showing me the changes to the previous version(build with eclipse), and it says that i have added 47 languages, but again, this is not true.
Screenshot from Play devconsole:
Screenshot from Play devconsole

I found this similar issue on Google code, but there is no response, i wish to solve this because i have to upload my new APK to Play.

Any idea how to get rid of these 47 other languages, while the library must stay imported with resources, to work properly?

UPDATE:
On Google code they say that this is expected for now and they were looking to add a way to select what you want to include in the apk.

How to solve:

At code.google.com they say that the gradle plugin has a option to restrict resources, since version 0.7.0 is released.

Note at version 0.7.0 Release notes:

New option on product Flavor (and defaultConfig) allow filtering of
resources through the -c option of aapt

  • You can pass single value (resConfig) or multiple values (resConfigs) through the DSL.
  • All values from the default config and flavors get combined and passed to aapt.
  • See “basic” sample.

Here is some sample code to put in the build.gradle file of your project:

android {
    defaultConfig {
        resConfigs "en", "de", "es" //Define languages that your app supports.
    }
}

I spent a lot of time to find the “Basic sample”…could be a link in the release notes :/ so there are the links:

NOTE:
Version 0.7.x requires Android Studio 0.4.+ and Gradle 1.9.

Leave a Reply

Your email address will not be published. Required fields are marked *