Android Studio 将字符串从支持库导出到 APK [英] Android Studio exports strings from support library to APK

查看:25
本文介绍了Android Studio 将字符串从支持库导出到 APK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我从 Eclipse 切换到 Android Studio.我有一个具有多个模块依赖项的项目.一种依赖是支持库 appcompat,包括如下:

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+"
}

在 Android 文档中,我发现这个库需要与资源一起导入,这似乎工作正常.我在我的项目中使用这个库没有问题.

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.

问题是,当我构建一个 APK 并运行 aapt 时,输出说:

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'

但事实并非如此,我的应用仅支持前 8 种列出的语言.当我将这个 apk 上传到 Play 时,它向我展示了对以前版本的更改(使用 Eclipse 构建),并且它说我添加了 47 种语言,但同样,这不是真的.Play devconsole 的截图:

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:

我在 Google 代码上发现了类似的问题,但是没有响应,我想解决这个问题,因为我必须上传我的新 APK 才能播放.

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.

知道如何摆脱这 47 种其他语言,同时图书馆必须保持导入资源才能正常工作吗?

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

更新:Google 代码上,他们说这是目前预期的他们希望添加一种方法来选择要包含在 apk 中的内容.

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.

推荐答案

At code.google.com 他们说 gradle 插件有一个选项来限制资源,因为版本 0.7.0 已经发布.

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

版本 0.7.0 发行说明:

产品风味(和 defaultConfig)上的新选项允许过滤资源通过 aapt 的 -c 选项

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

  • 您可以通过 DSL 传递单个值 (resConfig) 或多个值 (resConfigs).
  • 来自默认配置和风格的所有值被组合并传递给 aapt.
  • sample"">sample"3ebrelp"">sample"p"3>.

以下是一些示例代码,可放入项目的 build.gradle 文件中:

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:

  • Gradle samples
  • Basic sample
  • Release notes

注意:0.7.x 版本需要 Android Studio 0.4.+ 和 Gradle 1.9.

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

这篇关于Android Studio 将字符串从支持库导出到 APK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆