首页 文章

Android资源编译失败的原因何在?

提问于
浏览
0

我尝试了很多东西,但没有任何作用......

Android资源编译失败输出:C:\ Users \ user \ Desktop \ NEW android \ test1_tp7 \ app \ src \ main \ res \ layout \ activity_main.xml:1:错误:格式不正确(令牌无效) . 命令:C:\ Users \ user.gradle \ caches \ transforms-1 \ files-1.1 \ aapt2-3.2.1-4818971-windows.jar \ 2aa1a50b275688b3c8017d916765ab19 \ aapt2-3.2.1-4818971-windows \ aapt2.exe compile - -legacy \ -o \ C:\ Users \ user \ Desktop \ NEW android \ test1_tp7 \ app \ build \ intermediates \ res \ merged \ debug \ C:\ Users \ user \ Desktop \ NEW android \ test1_tp7 \ app \ src \ main \ res \ layout \ activity_main.xml守护程序:AAPT2 aapt2-3.2.1-4818971-windows守护程序#2

<?xmlversion="1.0"encoding="utf-8"?>

<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <TabWidget android:id="@android:id/tabs"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" />

    <FrameLayout android:id="@android:id/tabcontent"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <AnalogClock android:id="@+id/tab1"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" />
        <Button android:id="@+id/tab2"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:text="Unboutonpresquealéatoire" />


 </FrameLayout>
</LinearLayout>
</TabHost>

另外,当我运行我的项目时,我突然看不到我的手机设备 . 我试图下载谷歌USB驱动程序,清理项目,重新启动缓存,但似乎没有任何工作

enter image description here

2 回答

  • 3

    你在xml声明中缺少 space ?xml和版本,版本和编码 . 添加一个空格,它应该工作正常 .

    <?xml version="1.0" encoding="utf-8"?>
    
  • 0

    请关闭标签 <TabHost> 它将解决您的问题

    Follow the below code:

    <?xml version="1.0"encoding="utf-8"?>
    
    <TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/tabhost"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <LinearLayout android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
    
        <TabWidget android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />
    
        <FrameLayout android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">
            <AnalogClock android:id="@+id/tab1"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent" />
            <Button android:id="@+id/tab2"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:text="Unboutonpresquealéatoire" />
    
    
     </FrameLayout>
    </LinearLayout>
    </TabHost>
    

相关问题