首页 > 解决方案 > 我该如何解决这个错误: ParseError at [row,col]:[21,35]

问题描述

错误:

ParseError at [row,col]:[21,35] 消息:http ://www.w3.org/TR/1999/REC-xml-names-19990114#AttributePrefixUnbound?TextView&app:layout_constraintBottom_toBottomOf&app

AndroidManifest 文件:

<uses-permission android:name="android.permission.INTERNET" />

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/Theme.SwitchStuff">
    <activity android:name=".Login">
            <category android:name="android.intent.category.LAUNCHER" />
    </activity>
    <activity android:name=".SignUp" />
    <activity android:name=".MainActivity">
            <action android:name="android.intent.action.MAIN" />
    </activity>
</application>

build.gradle 文件:

plugins { id 'com.android.application' }

android { compileSdkVersion 30 buildToolsVersion "30.0.3"

defaultConfig {
    applicationId "com.mkrsudios.switchstuff"
    minSdkVersion 16
    targetSdkVersion 30
    versionCode 1
    versionName "1.0"

    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}
buildFeatures {
    viewBinding true
}
}

dependencies {

implementation 'com.github.VishnuSivadasVS:Advanced-HttpURLConnection:1.2'

implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.vectordrawable:vectordrawable:1.1.0'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.1'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1'
implementation 'androidx.navigation:navigation-fragment:2.3.5'
implementation 'androidx.navigation:navigation-ui:2.3.5'
implementation 'androidx.annotation:annotation:1.2.0'
implementation 'com.google.android.gms:play-services-auth:19.0.0'
implementation 'com.google.android.material:material:1.5.0-alpha01'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}

我不知道这个错误可能在哪里,但通过我的研究,这些文件中的任何一个

标签: androidxml

解决方案


请注意,categoryaction标签意味着在intent-filter标签内,而不是标签的直接子代activity

所以替换:

<activity android:name=".Login">
        <category android:name="android.intent.category.LAUNCHER" />
</activity>
<activity android:name=".MainActivity">
        <action android:name="android.intent.action.MAIN" />
</activity>

和:

<activity android:name=".Login">
    <intent-filter>
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>
<activity android:name=".MainActivity">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
    </intent-filter>
</activity>

您还需要使用发生错误的布局 xml 文件更新您的答案ParseError,以帮助您解决它。


推荐阅读