每次在Android Studio中创建新项目时,都会在colors.xml中收到此错误“错误:序言中不允许内容”。
我自动生成的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
当我通过在colors.xml中手动编写正确的代码来解决此错误时,就会出现此错误:
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
修改此错误后,就会出现此错误:
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
解决此错误之后,ic_launcher_foreground.xml和ic_launcher_background.xml中出现了相同的错误。解决我在运行项目时遇到的所有错误之后,另一个错误出现-运行“ app”时出错:找不到默认活动。因此,在编辑配置之后,我的应用程序可以正常运行,但是我必须在每个新项目中都遵循整个过程。请帮忙。