In android studio, the project sync is successful. But when I try to build or run the project it shows the error 'Content is not allowed in prolog'. I tried invalidate caches but in vain. I also tried to clean and rebuild project but it didn't work.
Here is my gradle build log
Task :app:processDebugResources [Fatal Error] aapt2-4.2.1-7147631.pom:2:1: Content is not allowed in prolog.
Task :app:processDebugResources FAILED
Execution failed for task ':app:processDebugResources'.
Could not isolate parameters com.android.build.gradle.internal.dependency.AarResourcesCompilerTransform$Parameters_Decorated@1b75aaee of artifact transform AarResourcesCompilerTransform Could not isolate value com.android.build.gradle.internal.dependency.AarResourcesCompilerTransform$Parameters_Decorated@1b75aaee of type AarResourcesCompilerTransform.Parameters > Could not resolve all files for configuration ':app:detachedConfiguration1'. > Could not resolve com.android.tools.build:aapt2:4.2.1-7147631. Required by: project :app > Could not resolve com.android.tools.build:aapt2:4.2.1-7147631. > Could not parse POM https://dl.google.com/dl/android/maven2/com/android/tools/build/aapt2/4.2.1-7147631/aapt2-4.2.1-7147631.pom > Content is not allowed in prolog.
I was using the latest version of gradle classpath dependency
classpath "com.android.tools.build:gradle:4.2.1"
I changed it to
classpath "com.android.tools.build:gradle:4.2.0"
Magically, all errors are gone.