Android Studio: Showing Copyright in xmls

Issue: Android Studio displaying XML code and causing project to not build

I recently encountered a problem where Android Studio suddenly displayed the following code:

<?xml version="1.0" encoding="utf-8"?>
  ~ Copyright (C) 2019 The Android Open Source Project
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the L

This caused my project to not be able to build. I tried creating a new project and it was fine, but I cannot recreate my project from scratch as I am close to completing it.

Does anyone have any experience with this issue?

This issue occurs when there is a missing or corrupted XML file in your project. To fix this issue, try the following steps:

  1. Open your project folder and navigate to the res folder.
  2. Look for any XML files that have an error icon next to them.
  3. If you find any, delete them and recreate them manually.
  4. Clean and rebuild your project.

If the issue persists, try deleting the .idea folder in your project directory and reopening your project in Android Studio. This will recreate the configuration files and may fix the issue.

Note: Before making any changes to your project, make sure to back up your code.