[英]How to solve "Failed to parse XML in AndroidManifest.xml"?
In Android Studio I have a sync error:在 Android Studio 中我有一个同步错误:
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.我将
android:hardwareAccelerated ="true"
添加到AndroidManifest.xml
但这并没有解决我的问题。 How should I resolve this?我应该如何解决这个问题?
AndroidManifest.xml 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'
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
Go to the project folder, in app ->> src ->> main and modify the AndroidManifest.xml with notepad.转到项目文件夹,在 app ->> src ->> main 中,用记事本修改 AndroidManifest.xml。
You need to put the -uses permission- between你需要把 -uses permission- 放在
<?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>
Just go to 70th line of your Manifest and you will find any special character like - @, ,,#.. And in my case it was a dot(,).只需转到您的清单的第 70 行,您就会发现任何特殊字符,例如 - @、,、#.. 在我的例子中,它是一个点 (,)。 I just removed the dot and error vanished.
我刚刚删除了点,错误就消失了。
Reason because ParseError at [row,col]:[70,1]原因是 [row,col]:[70,1] 处出现 ParseError
given that error is in 70th row.鉴于错误在第 70 行。
Your manifest should be of this format:您的清单应采用以下格式:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.test">
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<application
android:hardwareAccelerated="true">
...
</application>
</manifest>
https://developer.android.com/guide/topics/manifest/manifest-intro https://developer.android.com/guide/topics/manifest/manifest-intro
Just had that exact error when working on an older project and updating it.在处理旧项目并更新它时刚刚遇到了那个确切的错误。 I fixed it by opening the Manifest file in the text editor NotePadd++ and correcting issues with special characters.
我通过在文本编辑器 NotePadd++ 中打开清单文件并更正特殊字符问题来修复它。
In my manifest I had a special character just after my Internet Permission.在我的清单中,我在获得 Internet 许可后有一个特殊字符。 It said LS.
说的是LS。 Not sure what it was, but I removed the character, saved the XML, then tried running Gradle Sync again and it solved the problem.
不确定它是什么,但我删除了字符,保存了 XML,然后再次尝试运行 Gradle Sync,它解决了问题。 Go to line 70 of your Manifest file from a Text Editor and remove the special character, and then try to see if gradle will work after.
从文本编辑器转到 Manifest 文件的第 70 行并删除特殊字符,然后尝试查看 gradle 是否会在之后工作。
I had similar problem after updating the gradle... in my manifest i had..更新 gradle 后我遇到了类似的问题......在我的清单中我有......
<activity android:name=".motoController">
android:screenOrientation="landscape"
</activity>
and just changed it to并将其更改为
<activity android:name=".motoController"
android:screenOrientation="landscape"/>
And the problem was gone...问题消失了......
I Have this problem....我有这个问题....
Before前
<application
android:name=".data.ThisApplication"
android:allowBackup="true"
android:label="@string/app_name" />
After后
<application
android:name=".data.ThisApplication"
android:allowBackup="true"
android:label="@string/app_name"
I Just Remove "/>"我只是删除“/>”
No Error After this在此之后没有错误
[row,col] Check exact row and column number in Manifest file and remove any unnecessary characters then your problem will resolve. [row,col] 检查 Manifest 文件中的确切行号和列号并删除任何不需要的字符,然后您的问题就会解决。
If error didn't solved then try clean,rebuild or build project.如果错误没有解决,那么尝试清理、重建或构建项目。 Sometimes restarting the android studio will solve the solution.
有时重启android studio会解决问题。 Try Setting->Invalidate and Restart->Invalidate cache.
尝试设置->无效并重新启动->使缓存无效。
Any of the above solution will solve this error.上述任何解决方案都可以解决此错误。 If you have any other doubt ask it in comment box.
如果您有任何其他疑问,请在评论框中提问。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.