简体   繁体   English

android:摆脱“警告:编码 ascii 的不可映射字符”

[英]android: getting rid of “warning: unmappable character for encoding ascii”

I'm compiling using android tools without eclipse .我正在使用没有 eclipse 的android 工具进行编译。

I compile launching "ant debug" from command line.我编译从命令行启动“ant debug”。

I have found many many instructions around the web about how to remove with annoying warning, but I haven't been able to make any of them work.我在网上找到了很多关于如何删除恼人警告的说明,但我无法使它们中的任何一个工作。

I've tried -D option, I've tried randomly tweaking build.* files, I've tried exporting an environment variable... nothing.我试过 -D 选项,我试过随机调整 build.* 文件,我试过导出环境变量......什么都没有。

I guess some of these methods just don't work, and some others would work but I've been doing them incorrectly.我想其中一些方法不起作用,而另一些方法会起作用,但我一直做错了。 Anything is possible and I can't stand it any more: any advice on how to do it?一切皆有可能,我再也受不了了:关于如何做到这一点有什么建议吗?

I had the same problem.我有同样的问题。 This is how I solved it:我是这样解决的:

When I launch ant release , there is this line in the output: [setup] Importing rules file: tools/ant/ant_rules_r3.xml .当我启动ant release ,输出中有这一行: [setup] Importing rules file: tools/ant/ant_rules_r3.xml I edited ant_rules_r3.xml and replaced "ascii" with "UTF8".我编辑了ant_rules_r3.xml并将“ascii”替换为“UTF8”。

While it is certainly possible to tweak the system defaults in the Android SDK, such attempts may lead to unpredicted and non-standard behaviour of ANT.虽然当然可以在 Android SDK 中调整系统默认值,但这种尝试可能会导致 ANT 出现不可预测和非标准的行为。 Some other bit of the system may expect the default behaviour of ANT or an update will undo your changes.系统的其他部分可能期望 ANT 的默认行为或更新将撤消您的更改。 Also if you attempt to compile the project on a different system such as a build server or a team member's computer, you will need to remember to tweak every system involved.此外,如果您尝试在不同的系统(例如构建服务器或团队成员的计算机)上编译项目,则需要记住调整所涉及的每个系统。 As such system tweaks should be avoided and are not recommended.因此,应避免且不建议进行此类系统调整。

ANT build process accepts per project overrides for system wide defaults. ANT 构建过程接受每个项目覆盖系统范围的默认值。 While it does require an additional file for every project, it is likely to give more consistent build behaviour on all development platforms and ease development, diagnostics and maintenance.虽然它确实需要为每个项目添加一个额外的文件,但它可能会在所有开发平台上提供更一致的构建行为,并简化开发、诊断和维护。

I am using ANT 1.8.4 and providing a build.properties file as suggested by Whome didn't work for me but it is a step in the right direction.我正在使用 ANT 1.8.4 并提供一个由Whome建议的 build.properties 文件对我不起作用,但这是朝着正确方向迈出的一步。 I had to create an ant.properties file (for every project) and provide overrides just as Whome suggested.我必须创建一个ant.properties文件(对于每个项目)并按照Whome 的建议提供覆盖。

It is however a bad idea to provide these overrides in any other file, such as local.properties or build.xml files.然而,在任何其他文件(例如local.propertiesbuild.xml文件)中提供这些覆盖是一个坏主意。 These files are created and modified by the android tool.这些文件由 android 工具创建和修改。

I do recommend the reader to read the build.xml file as it is well documented and provides excellent hints and instructions on how to use the Android ANT build system.我建议读者阅读build.xml文件,因为它有很好的文档记录,并提供了关于如何使用 Android ANT 构建系统的极好的提示和说明。

The next interesting bit of reading is the root ANT build script located in android-sdk/tools/ant/build.xml .下一个有趣的阅读是位于android-sdk/tools/ant/build.xml的根 ANT 构建脚本。 This file will list all overridable properties such as:该文件将列出所有可覆盖的属性,例如:

java.target=1.6
verbose=true

But the encoding is set just as it was previously suggested by Whome :但是编码的设置就像Whome之前建议的那样

## Override default ANT properties
java.encoding=ISO-8859-1

I have android-10 SDK kit, this is how I fixed an encoding warning while building a project.我有 android-10 SDK 套件,这是我在构建项目时修复编码警告的方式。 * create c:/myproject/build.properties file * override default ANT variables * 创建 c:/myproject/build.properties 文件 * 覆盖默认的 ANT 变量

## Override default ANT properties
java.encoding=ISO-8859-1

任何正在寻找解决方案的人,在gradle.properties设置以下内容都为我解决了gradle.properties问题。

org.gradle.jvmargs='-Dfile.encoding=UTF-8'

For the swedish character set, I did as fhucho suggested.对于瑞典语字符集,我按照 fhucho 的建议做了。 But I had to use ISO-8859-1 instead of UTF-8.但我不得不使用 ISO-8859-1 而不是 UTF-8。 So maybe it is better to use ISO encodings instead.所以也许最好改用 ISO 编码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM