索引 51 处的非法字符 <:>:com.example.AppName.app-mergeDebugResources-29:/values/values.xml



你好,我正在尝试编译和运行我的Android项目,这个错误已经发生

非法字符<:>在索引51:com.example. capstoneccafe .app- mergedebugresources -29:/values/values.xml

我已经检查了

下面的value .xml
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:ns1="http://schemas.android.com/tools" 
xmlns:ns2="urn:oasis:names:tc:xliff:document:1.2">
<attr format="enum" name="animateCircleAngleTo">
<enum name="bestChoice" value="0"/>
<enum name="closest" value="1"/>
<enum name="clockwise" value="2"/>
<enum name="antiClockwise" value="3"/>
<enum name="constraint" value="4"/>
</attr>

我在这个文件中有两个错误

xmlns:ns1="http://schemas.android.com/tools" 
xmlns:ns2="urn:oasis:names:tc:xliff:document:1.2"

如果我删除一个或其他许多其他错误出现在文件上。我试着把这行代码放在我的gradle属性

android.enableJetifier=true

但是我的应用程序在构建成功后立即关闭

完整错误输出

1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
> A failure occurred while executing 
com.android.build.gradle.internal.res.ResourceCompilerRunnable
> Resource compilation failed (Failed to compile values resource file  
Cause: java.nio.file.InvalidPathException: Illegal char <:> at index 
51: com.example.capstonecafe.app-mergeDebugResources- 
29:/values/values.xml). Check logs for more details.

Activity.xml的依赖

<?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=".MainActivity"
android:background="@drawable/bg1">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:orientation="vertical">
<ImageView
android:layout_width="200dp"
android:layout_height="200dp"
android:src="@drawable/cafeh"
android:layout_gravity="center"/>
<TextView
android:layout_width="200dp"
android:layout_height="wrap_content"
android:gravity="center"
android:id="@+id/txtquote"
android:text="@string/quote"
android:layout_gravity="center"
android:textColor="#6E2C00"
android:textStyle="bold"
android:fontFamily="@font/carterone_regular"
android:textSize="15dp"/>


</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_alignParentBottom="true"
android:weightSum="2">
<info.hoang8f.widget.FButton
android:id="@+id/btnsignup"
app:buttonColor="@color/white"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:layout_weight="1"
android:text="Sign Up"
android:textColor="#6E2C00"
app:cornerRadius="4dp"
app:shadowColor="#6E2C00"
app:shadowEnabled="true"
app:shadowHeight="5dp" />
<info.hoang8f.widget.FButton
android:id="@+id/btnsignin"
app:buttonColor="@color/white"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:layout_weight="1"
android:text="Sign In"
android:textColor="#6E2C00"
app:cornerRadius="4dp"
app:shadowColor="#6E2C00"
app:shadowEnabled="true"
app:shadowHeight="5dp" />
</LinearLayout>
</RelativeLayout>

我猜您已经在调试值中打开了values.xml文件。这些文件不应该被编辑。对于您的错误,您可以尝试以下

中的任何一个
  1. 首先尝试无效并重新启动缓存,然后看看是否有效
  2. 如果仍然不起作用,检查res目录下的所有xml文件,看看你在哪里错误地输入了<:>字符