错误 2:错误:格式不正确(令牌无效)



我正在尝试在安卓工作室中运行该项目,它给出了一个完整的错误:-

安卓资源编译失败 C:\Users\mohammadfarooq\Desktop\MaterialWallpaper\app\src\main\res\layout\layout_recent_wallpaper.xml:2: 错误:格式不正确(令牌无效(。 C:\Users\mohammadfarooq\Desktop\MaterialWallpaper\app\src\main\res\layout\layout_recent_wallpaper.xml: 错误:文件编译失败。

<?xml version="1.0" encoding="utf-8"?>1<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/rootlayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<GridView
    android:id="@+id/latest_grid"
    android:layout_width="fill_parent"
    android:layout_height="match_parent"
    android:numColumns="auto_fit"
    android:stretchMode="columnWidth"
    android:layout_above="@+id/adView" />
<com.google.android.gms.ads.AdView
    android:id="@+id/adView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    ads:adSize="BANNER"
    android:visibility="@string/admob_visibility"
    ads:adUnitId="@string/admob_publisher_id" />

问题就在这里

<?xml version="1.0" encoding="utf-8"?> 1 <RelativeLayout

您需要从布局文件中删除1

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    android:id="@+id/rootlayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <GridView
        android:id="@+id/latest_grid"
        android:layout_width="fill_parent"
        android:layout_height="match_parent"
        android:numColumns="auto_fit"
        android:stretchMode="columnWidth"
        android:layout_above="@+id/adView" />
    <com.google.android.gms.ads.AdView
        android:id="@+id/adView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        ads:adSize="BANNER"
        android:visibility="@string/admob_visibility"
        ads:adUnitId="@string/admob_publisher_id" />
</RelativeLayout>

从布局 XMl 的第一行中删除 1。

1

最新更新