【问题标题】:Error:(1) Error parsing XML: encoding specified in XML declaration is incorrect. What's wrong?错误:(1) 解析 XML 时出错:XML 声明中指定的编码不正确。怎么了?
【发布时间】:2017-12-19 14:52:14
【问题描述】:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.molitveniseznamkackrko.MainActivity">

    <WebView
        android:id="@+id/webview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        tools:layout_editor_absoluteX="8dp"
        tools:layout_editor_absoluteY="8dp" />
</RelativeLayout>

这里是代码。错误指向第一行。如果我使用 utf-16,则应用程序在模拟器中运行,但我无法构建 apk 文件(错误:(1)错误:utf-16:不使用 UTF-8 作为文件编码。这可能会导致细微的错误非 ASCII 字符 [EnforceUTF8])。我做错了什么?

【问题讨论】:

  • 确保顶部没有空行/空格
  • 没有。如果它可能有帮助,当我想要自定义 TTF 字体时,这个错误开始出现。然后我决定不使用自定义字体。

标签: android xml encoding utf-8


【解决方案1】:

我找到了解决办法。我已经复制了除&lt;?xml version="1.0" encoding="utf-8"?&gt; 之外的所有内容,并制作了新的布局文件并将其粘贴到那里。它现在有效。仍然不知道是什么问题,但这并不重要。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-08-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-26
    • 1970-01-01
    相关资源
    最近更新 更多