简体   繁体   English

为什么Visual Studio(Xamarin)中的Android资源文件不允许有重音符号?

[英]Why are Android Asset files in Visual Studio (Xamarin) not allowed to have accents?

I have a Visual Studio (Xamarin, Android) project with a file which has an accent character in the name: 我有一个Visual Studio(Xamarin,Android)项目,其文件名称中包含重音字符:

 diário.png

This file is in the Assets folder, and marked as an Android Asset. 此文件位于Assets文件夹中,并标记为Android资产。

在此输入图像描述

Unfortunately when I build the project, I get a compile error: 不幸的是,当我构建项目时,我收到编译错误:

C:\\Users\\vchel\\Documents\\FlatRedBallProjects\\AndroidSpecialCharacter\\AndroidSpecialCharacter\\obj\\Debug\\assets\\content\\gumproject\\dißrio.png : error : Invalid filename. Unable to add.

Notice that the file is diário.png in my project, but the error references it as dißrio.png. 请注意,我的项目中的文件是diário.png,但错误将其引用为dißrio.png。

If I rename the file to diario.png (no accent above the letter a) the project builds fine. 如果我将文件重命名为diario.png(字母a之上没有重音),项目构建正常。

I know I could work around this by not using accent characters in my file but this seems like a strange restriction. 我知道我可以通过不在我的文件中使用重音字符解决这个问题,但这似乎是一个奇怪的限制。 Is this a known issue? 这是一个已知的问题? Is there another way to solve this other than avoiding using accents in file names? 除了避免在文件名中使用重音之外,还有其他方法可以解决这个问题吗?

Asset naming restrictions are bound all the way back to Android API 1 , the related build tools and .apk packaging (and has nothing to due with the Xamarin framework). 资产命名限制一直限制在Android API 1 ,相关的构建工具和.apk打包(并且与Xamarin框架没有任何关系)。

  • Valid characters for naming resources are [az, _, 0–9] 命名资源的有效字符是[az,_,0-9]

    • Lowercase characters, numbers, and underscore 小写字符,数字和下划线
  • Use an underscore ( _ ) as a multi-name separator between "words" in your assets 使用下划线( _ )作为资产中“单词”之间的多名称分隔符

    • Spaces hyphens, and periods are not allowed 空格连字符,不允许有句号
  • The first letter can be either _ or a small case character 第一个字母可以是_或小写字母

    • Numbers are not allowed as the first character 不允许数字作为第一个字符

Note: There used to be notes on these restrictions on the Android Developer site, but I can no longer find them as they stripped out most docs for the build tools 注意:以前在Android开发者网站上有关于这些限制的注释,但我无法再找到它们,因为它们删除了构建工具的大多数文档

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

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