简体   繁体   中英

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

I'm compiling using android tools without eclipse .

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.

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 . I edited ant_rules_r3.xml and replaced "ascii" with "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. Some other bit of the system may expect the default behaviour of ANT or an update will undo your changes. 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. 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. I had to create an ant.properties file (for every project) and provide overrides just as Whome suggested.

It is however a bad idea to provide these overrides in any other file, such as local.properties or build.xml files. These files are created and modified by the android tool.

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.

The next interesting bit of reading is the root ANT build script located in android-sdk/tools/ant/build.xml . 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 :

## 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. * create c:/myproject/build.properties file * override default ANT variables

## 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. But I had to use ISO-8859-1 instead of UTF-8. So maybe it is better to use ISO encodings instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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