How to solve "Failed to parse XML in AndroidManifest.xml"?

19,227

Solution 1

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

Go to the project folder, in app ->> src ->> main and modify the AndroidManifest.xml with notepad.

You need to put the -uses permission- between

 <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.exemple">

and

<application>
</application>

Solution 2

Just go to 70th line of your Manifest and you will find any special character like - @, !,#,. And in my case it was a dot(.) , I just removed the dot and error vanished.

Reason because ParseError at [row,col]:[70,1]

given that error is in 70th row.

Share:
19,227
Glembinek
Author by

Glembinek

Updated on June 04, 2022

Comments

  • Glembinek
    Glembinek almost 2 years

    In Android Studio I have a sync error:

    ERROR: Failed to parse XML in C:\...\app\src\main\AndroidManifest.xml
    ParseError at [row,col]:[70,1]
    Message: expected start or end tag
    Affected Modules: app
    

    I added android:hardwareAccelerated ="true" to AndroidManifest.xml but this did not fix my problem. How should I resolve this?

    AndroidManifest.xml

    <!--android:hardwareAccelerated ="true"-->
    <application
        android:name=".App"
        android:allowBackup="true"
        android:icon="@drawable/icon"
        android:label="@string/app_name"
        android:roundIcon="@drawable/icon_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.MaterialComponents.Light.NoActionBar"
        android:hardwareAccelerated="true">
        <activity
            android:name=".SelectColor"
            android:screenOrientation="sensorPortrait"/>
        <activity
            android:name=".AddAimActivity"
            android:screenOrientation="sensorPortrait"/>
        <activity
            android:name=".MainActivity"
            android:screenOrientation="sensorPortrait">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
    
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".PopActivity"
            android:screenOrientation="sensorPortrait"/>
        <activity
            android:name=".AddActionAtivity"
            android:theme="@style/AppTheme"
            android:screenOrientation="sensorPortrait" />
        <activity
            android:name=".SelectIconActivity"
            android:screenOrientation="sensorPortrait"/>
        <activity
            android:name=".EditActionActivity"
            android:theme="@style/AppTheme"
            android:screenOrientation="sensorPortrait"/>
        <activity
            android:name=".EditRoutineActivity"
            android:theme="@style/AppTheme"
            android:screenOrientation="sensorPortrait"/>
    
        <activity
            android:name=".EditAimActivity"
            android:theme="@style/AppTheme"
            android:screenOrientation="sensorPortrait"/>
        <activity
            android:name=".AddReminder"
            android:screenOrientation="sensorPortrait"/>
    
        <receiver
            android:name=".AlarmReceiver"
            android:screenOrientation="sensorPortrait"/>
    
        <activity
            android:name=".AddRoutine"
            android:theme="@style/AppTheme"
            android:screenOrientation="sensorPortrait"/>
        <service android:name="net.eagledev.planner.BackgroundService" android:exported="false" />
        <service android:name=".NotificationService"/>
    
    </application>
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
    

    App module

    compileSdkVersion 28
    defaultConfig {
        applicationId "net.eagledev.planner"
        minSdkVersion 23
        targetSdkVersion 28
        versionCode 5
        versionName "0.6"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    packagingOptions {
        exclude 'META-INF/proguard/androidx-annotations.pro'
    
    }}
    

    Dependencies

    implementation fileTree(dir: 'libs', include: ['*.jar'])
    //noinspection GradleCompatible
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0-alpha'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.getbase:floatingactionbutton:1.10.1'
    implementation 'com.github.clans:fab:1.6.2'
    implementation 'com.google.code.gson:gson:2.8.5'
    implementation 'com.android.support:recyclerview-v7:28'
    implementation 'com.android.support:cardview-v7:28.0.0'
    implementation 'com.android.support:recyclerview-selection:28.0.0'
    def room_version = "1.1.1"
    implementation "android.arch.persistence.room:runtime:$room_version"
    annotationProcessor "android.arch.persistence.room:compiler:$room_version"
    implementation 'com.android.support:gridlayout-v7:28.0.0'