Andriod Build问题无法解析XML

时间:2019-11-19 17:29:31

标签: android xml android-gradle-plugin android-manifest

我在清单文件中的android应用程序中遇到构建问题,我收到以下错误消息:

  

错误:无法解析D:\ TA Android \ TAApp \ app \ src \ main \ AndroidManifest.xml中的XML       [row,col]处的ParseError:[42,5]       消息:预期的开始或结束标记       受影响的模块:应用

我在给定的行号中看不到任何错误,任何人都可以帮我解决什么问题吗?

成绩文件:

    apply plugin: 'com.android.application'

    android {
        compileSdkVersion  29
        buildToolsVersion  "29.0.1"
        project.archivesBaseName = "MassC";
        defaultConfig {
            applicationId "com.example"
            minSdkVersion 15
            targetSdkVersion 29
            versionCode 1
            versionName "2.0"
            testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            }
        }

    }

    dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
        implementation 'androidx.appcompat:appcompat:1.0.2'
        implementation 'com.google.android.material:material:1.0.0'
        implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
        implementation 'androidx.annotation:annotation:1.1.0'
        implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
        testImplementation 'junit:junit:4.12'
        androidTestImplementation 'androidx.test:runner:1.2.0'
        androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
        implementation 'com.squareup.retrofit2:retrofit:2.3.0'
        implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
        implementation 'com.jakewharton.picasso:picasso2-okhttp3-downloader:1.1.0'

    }

清单文件

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.ta_app_ui">
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.CALL_PHONE" />
    <uses-permission android:name="android.permission.INTERNET" />

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

    <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/AppTheme">
        <activity android:name=".ui.signup.SignupActivity"></activity>
        <activity
            android:name=".ui.login.LoginActivity"
            android:label="@string/title_activity_login">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".ui.sidebar.MainActivity"
            android:label="@string/app_name"
            android:theme="@style/AppTheme.NoActionBar"></activity>
        <activity
            android:name=".ui.candidate_details.ViewUserDataActivity"
            android:parentActivityName=".ui.sidebar.MainActivity">

            <!-- The meta-data tag is required if you support API level 15 and lower -->
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value=".ui.sidebar.MainActivity" />
        </activity>
        android:label="@string/app_name"
    </application>

</manifest>


When I try to build ,I get error as Failed to Parse XML  in ...path..\AndriodManifest.xml ParseError

----Snippet----

enter image description here

2 个答案:

答案 0 :(得分:0)

最后从您的android:label="@string/app_name"中删除Manifest.xml。完整的xml应该是这样的:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.ta_app_ui">
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.CALL_PHONE" />
    <uses-permission android:name="android.permission.INTERNET" />

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

    <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/AppTheme">
        <activity android:name=".ui.signup.SignupActivity"></activity>
        <activity
            android:name=".ui.login.LoginActivity"
            android:label="@string/title_activity_login">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".ui.sidebar.MainActivity"
            android:label="@string/app_name"
            android:theme="@style/AppTheme.NoActionBar"></activity>
        <activity
            android:name=".ui.candidate_details.ViewUserDataActivity"
            android:parentActivityName=".ui.sidebar.MainActivity">

            <!-- The meta-data tag is required if you support API level 15 and lower -->
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value=".ui.sidebar.MainActivity" />
        </activity>
    </application>

</manifest>

答案 1 :(得分:0)

只需删除 android:label =“ @ string / app_name” 从清单文件中 就这样