0

I get this error "Error: Content is not allowed in prolog" in colors.xml everytime when I create a new project in Android Studio.

My auto generated colors.xml :

/* AUTO-GENERATED FILE.  DO NOT MODIFY.** This class was automatically 
generated by the* gradle plugin from the resource data it found. It* should not 
be modified by hand.*/package android.ar

When I resolve this error by manually writing the correct code in colors.xml, this error comes :

Android resource compilation failed
Output:  C:\Users\Lenovo\AndroidStudioProjects\WhatstheWhether\app\src\main\res\mipmap-anydpi-v26\ic_launcher_round.xml:1: error: not well-formed (invalid token).

Command: C:\Users\Lenovo\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.1-4818971-windows.jar\3fe9903feff1f1df45dbb24febdc7fc3\aapt2-3.2.1-4818971-windows\aapt2.exe compile --legacy \
    -o \
C:\Users\Lenovo\AndroidStudioProjects\WhatstheWhether\app\build\intermediates\res\merged\debug \
    C:\Users\Lenovo\AndroidStudioProjects\WhatstheWhether\app\src\main\res\mipmap-anydpi-v26\ic_launcher_round.xml
Daemon:  AAPT2 aapt2-3.2.1-4818971-windows Daemon #0

anydpi-v26\ic_launcher_round.xml :

/* AUTO-GENERATED FILE.  DO NOT MODIFY.** This class was automatically generated by the* gradle plugin from the resource data it found. It* should not be modified by hand.*/package android.support.localbroadcastmanager;

public final class R {pr

After resloving this , this error comes :

Android resource compilation failed
 Output: C:\Users\Lenovo\AndroidStudioProjects\WhatstheWhether\app\src\main\res\mipmap-anydpi-v26\ic_launcher.xml:1: error: not well-formed (invalid token).

 Command: C:\Users\Lenovo\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.1-4818971-windows.jar\3fe9903feff1f1df45dbb24febdc7fc3\aapt2-3.2.1-4818971-windows\aapt2.exe compile --legacy \
    -o \
    C:\Users\Lenovo\AndroidStudioProjects\WhatstheWhether\app\build\intermediates\res\merged\debug \
    C:\Users\Lenovo\AndroidStudioProjects\WhatstheWhether\app\src\main\res\mipmap-anydpi-v26\ic_launcher.xml
    Daemon:  AAPT2 aapt2-3.2.1-4818971-windows Daemon #0

After resolving this error, same error comes in ic_launcher_foreground.xml and ic_launcher_background.xml . After resolving all these errors when I run my project , another error comes - Error running 'app': Default Activity not found . So after editing configurations , my app runs fine but I have to follow this whole procedure in every new project. Please help.

Swappy
  • 160
  • 1
  • 7
  • 29
  • And you get these when you create a new project in Android Studio? Could you please try to invalidate caches, restart and create a new project? – Izabela Orlowska Dec 18 '18 at 11:30
  • @IzabelaOrlowska still the same error I am getting when creating a new project. – Swappy Dec 18 '18 at 18:09
  • This error gets resolved after Syncing project with gradle files but after few minutes it comes again. – Swappy Dec 18 '18 at 18:11
  • Looks like something is making android studio overwrite your resources with the R class sources (which really should not be happening). Can you file a bug for the android studio team at https://issuetracker.google.com/issues/new?component=192708&template=840533 ? – Izabela Orlowska Dec 19 '18 at 11:18
  • Does this answer your question? [Android Studio shows wrong file contents](https://stackoverflow.com/questions/53249677/android-studio-shows-wrong-file-contents) – Dalija Prasnikar Dec 06 '19 at 08:48

0 Answers0