当前位置: 首页 > 知识库问答 >
问题:

Android错误-AGPBI:{“种类”:“错误”,“文本”:“解析XML时出错:格式不正确(无效标记)”

嵇永望
2023-03-14

我需要将一个工作项目从Eclipse导入Android Studio 2.1,并从Gradle控制台收到以下消息

正在执行的任务:[:app:generateDebugSources,:app:mockableAndroidJar,:app:prepareDebugUnitTestDependencies,:app:generateDebugAndroidTestSources]

按需配置是一个孵化功能。增量java编译是一个孵化功能。: app: preBuild UP-TO-DATE: app: preDebugBuild UP-TO-DATE: app: check DebugManiFestival: app: preRelaseBuild UP-TO-DATE: app: preareComAndreidSupportAnimatedVectorDrawable2330库: app: preareComAndreidSupportAppcompatV72330库: app: preCompareComAndreidSupportSupportV42330库: app: preDebugBuildSupportVectorDrawable2330库: app: prebuareDebugDependance: app: compileDebugAidl: app: compileDebugRendercript: app: GenerateDebugBuildConfig UP-TO-DATE: app: comgeDebugShaders UP-TO-DATE: app:编译DebugShaders: app:生成DebugAsset: app: mergeDebugAsset UP-TO[{"file":"C:\用户\Advanchip\StudioProjects\Mobile-ControlledLighting\app\src\main\res\布局\dialog_add_gateway.xml","位置":{"起始线": 0}}],"原始":"工具":"AAPT"}

失败了

失败:生成失败,出现异常。

>

通用域名格式。Android石斑鱼类。常见的过程ProcessException:org。格雷德尔。过程内部的ExeceException:处理“命令”C:\Users\advanchip\AppData\Local\Android\sdk\build tools\23.0.3\aapt。exe“”已完成,退出值为非零1

尝试:使用--stacktrace选项运行以获取堆栈跟踪。使用--info或--debug选项运行以获得更多日志输出。

构建失败

总时间:12.676秒

    The codes of the xml file is

<!DOCTYPE LinearLayout [<!ELEMENT LinearLayout (LinearLayout|Spinner|EditText|Button)*><!ATTLIST LinearLayoutandroid:background CDATA #IMPLIEDandroid:gravity CDATA #IMPLIEDandroid:id CDATA #IMPLIEDandroid:layout_height CDATA #REQUIREDandroid:layout_width CDATA #REQUIREDandroid:orientation CDATA #REQUIREDandroid:paddingBottom CDATA #IMPLIEDandroid:paddingLeft CDATA #IMPLIEDandroid:paddingRight CDATA #IMPLIEDandroid:paddingTop CDATA #IMPLIEDxmlns:android CDATA #IMPLIEDxmlns:tools CDATA #IMPLIED><!ELEMENT Spinner (#PCDATA)><!ATTLIST Spinnerandroid:id CDATA #REQUIREDandroid:layout_width CDATA #REQUIREDandroid:layout_height CDATA #REQUIREDandroid:layout_gravity CDATA #REQUIREDandroid:layout_marginTop CDATA #REQUIREDandroid:background CDATA #REQUIREDandroid:maxLines CDATA #REQUIREDandroid:paddingBottom CDATA #REQUIREDandroid:paddingTop CDATA #REQUIREDandroid:textStyle CDATA #REQUIRED><!ELEMENT EditText (#PCDATA)><!ATTLIST EditTextandroid:id CDATA #REQUIREDandroid:layout_width CDATA #REQUIREDandroid:layout_height CDATA #REQUIREDandroid:layout_gravity CDATA #REQUIREDandroid:layout_marginTop CDATA #REQUIREDandroid:background CDATA #REQUIREDandroid:hint CDATA #REQUIREDandroid:maxLines CDATA #REQUIREDandroid:paddingBottom CDATA #REQUIREDandroid:paddingLeft CDATA #REQUIREDandroid:paddingRight CDATA #REQUIREDandroid:paddingTop CDATA #REQUIREDandroid:singleLine CDATA #REQUIREDandroid:textColor CDATA #REQUIREDandroid:textStyle CDATA #REQUIRED><!ELEMENT Button (#PCDATA)><!ATTLIST Buttonandroid:background CDATA #REQUIREDandroid:id CDATA #REQUIREDandroid:layout_gravity CDATA #REQUIREDandroid:layout_height CDATA #REQUIREDandroid:layout_marginTop CDATA #REQUIREDandroid:layout_width CDATA #REQUIREDandroid:text CDATA #REQUIREDandroid:textSize CDATA #REQUIRED>]>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#011f4b"
    android:gravity="center_horizontal"
    android:orientation="vertical"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingLeft="5dp"
    android:paddingRight="5dp" >

    <LinearLayout
        android:id="@+id/add_gateway_form"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <Spinner
            android:id="@+id/gatewaySerial"
            android:layout_width="match_parent"
            android:layout_height="40sp"
            android:layout_gravity="center_horizontal"
            android:layout_marginTop="20sp"
            android:background="@drawable/rect_text_edit"
            android:maxLines="1"
            android:paddingBottom="5dp"
            android:paddingTop="5dp"
            android:textStyle="bold"
             />

        <EditText
            android:id="@+id/gatewayName"
            android:layout_width="match_parent"
            android:layout_height="40sp"
            android:layout_gravity="center_horizontal"
            android:layout_marginTop="10sp"
            android:background="@drawable/rect_text_edit"
            android:hint="Gateway Name"
            android:maxLines="1"
            android:paddingBottom="5dp"
            android:paddingLeft="5dp"
            android:paddingRight="5dp"
            android:paddingTop="5dp"
            android:singleLine="true"
            android:textColor="#008bcb"
            android:textStyle="bold" />

        <Button
            android:id="@+id/add_gateway_button"
            android:layout_width="200sp"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:layout_marginTop="16dp"
            android:background="@drawable/submit_button_bg"
            android:text="Create Gateway"
            android:textSize="18sp" />

        <Button
            android:id="@+id/dialog_cancel"
            android:layout_width="200sp"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:layout_marginTop="16dp"
            android:background="@drawable/submit_button_bg"
            android:text="Cancel"
            android:textSize="18sp" />
    </LinearLayout>

</LinearLayout>

应用程序build.gradle的html" target="_blank">代码是

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"
    useLibrary 'org.apache.http.legacy'

    defaultConfig {
        applicationId "com.advanchip.mobile_controlledlighting"
        minSdkVersion 17
        targetSdkVersion 23
        versionCode 1
        versionName "1.0" 
    }
    buildTypes {
        release {
            minifyEnabled false
            //proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
       }
    }
    productFlavors { 
    }
}

dependencies {
    //compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:support-v4:23.3.0'
    compile 'com.android.support:appcompat-v7:23.3.0'
    //compile 'com.android.support:support-v4:22.2.0'
    //compile 'com.android.support:appcompat-v7:22.2.0'
    //compile "com.android.support:support-v4:18.0.+"
    //compile "com.android.support:appcompat-v7:18.0.+"
    compile files('libs/commons-lang-2.6.jar')
    compile files('libs/commons-logging-1.1.2.jar')
    compile files('libs/httpmime-4.0.1.jar')
    compile files('libs/smartconfiglib.jar')
}

Android SDK管理器的图像

    The codes of rect_text_edit.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"

    android:shape="rectangle" >

    <solid android:color="#ffffff" />



</shape>


    The codes of submit_button_bg.xml

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

<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:state_pressed="true"
        android:drawable="@color/button_pressed" />

    <item android:state_enabled="true"
        android:drawable="@color/button_normal" />
</selector>


    Please advise, thanks.

共有1个答案

王昊
2023-03-14

在您的XML中有一行是不相关的,删除以下行

 类似资料:
  • 我有XML数据在数据库(不是文件),我需要解析它,以提供可能写测试来验证数据在XML xml(内容数据): [致命错误]:14:2:根元素后面的文档中的标记必须格式良好。org.xml.sax.SaxParseException;亚麻编号:14;专栏编号:2;根元素后面的文档中的标记必须格式良好。位于com.sun.org.apache.xerces.internal.parsers.dompar

  • 到处都找不到。我已经找了一个多小时了,现在运气不佳。你看到了吗?

  • 我不明白为什么我一直收到这个错误消息: 在此行中找到多个注释: < li >文档中根元素后面的标记必须格式良好。 < li >错误:解析XML时出错:文档元素后的垃圾信息 该错误在下面的开头找到: XML:

  • 问题内容: 目前,我正在开发一项功能,该功能涉及解析从另一产品收到的XML。我决定对一些实际的客户数据进行一些测试,看起来其他产品正在允许来自用户的输入被认为是无效的。无论如何,我仍然必须尝试找出一种解析它的方法。我们正在使用,但输入出现错误,如下所示。 如你所知,说明中包含似乎是无效标签的内容。现在,此描述标签被称为是叶子标签,并且其中不应包含任何嵌套标签。无论如何,这仍然是一个问题,并且会在

  • 我有以下错误:错误:(2)解析XML时出错:格式不正确(无效令牌) 错误:任务执行失败:应用程序:进程DebugResources。 com.android.ide.common.process.ProcessExcture:org.gradle.process.internal.ExecExc0019:进程'命令'E:\AndroidSdk\sdk\build-ols\23.0.2\aapt.e

  • 问题内容: 我有一个使用JDOM和xpath解析XML文件的过程,如下所示: 以上工作正常。xpath表达式存储在属性文件中,因此可以随时更改它们。现在,我必须处理更多来自旧系统的xml文件,该旧系统将仅以4000字节的块发送xml文件。现有处理读取4000字节的块并将其存储在Oracle数据库中,每个块作为数据库中的一行(对遗留系统进行任何更改或将这些块存储为数据库中的行的处理都是不可能的) 。