gpt4 book ai didi

java - 如何修复 ic_launcher_foregorund.xml 意外标记和未找到顶级元素

转载 作者:行者123 更新时间:2023-12-02 09:50:08 25 4
gpt4 key购买 nike

我正在构建一个 TODO 应用程序,当我想运行我的应用程序时,我收到此错误,该错误表明 v23/ic_launcher_foreground.xml 中存在问题,代码如下

<adaptive-icon
xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="white"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>

问题是1.意外的 token
2. 未找到顶级元素

错误

Executing tasks: [:app:assembleDebug]

> Task :app:preBuild UP-TO-DATE
> Task :app:preDebugBuild UP-TO-DATE
> Task :app:compileDebugAidl NO-SOURCE
> Task :app:compileDebugRenderscript NO-SOURCE
> Task :app:checkDebugManifest UP-TO-DATE
> Task :app:generateDebugBuildConfig UP-TO-DATE
> Task :app:prepareLintJar UP-TO-DATE
> Task :app:generateDebugSources UP-TO-DATE
> Task :app:javaPreCompileDebug UP-TO-DATE
> Task :app:mainApkListPersistenceDebug UP-TO-DATE
> Task :app:generateDebugResValues UP-TO-DATE
> Task :app:generateDebugResources UP-TO-DATE
> Task :app:mergeDebugResources FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
> 1 exception was raised by workers:
com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource compilation failed
C:\Users\CHARAN\Desktop\Android Development\BPTODO\app\src\main\res\drawable-v24\ic_launcher_foreground.xml:40: error: not well-formed (invalid token).
C:\Users\CHARAN\Desktop\Android Development\BPTODO\app\src\main\res\drawable-v24\ic_launcher_foreground.xml: error: file failed to compile.



* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 27s
8 actionable tasks: 1 executed, 7 up-to-date

最佳答案

我认为意想不到的标记指的是“白色”这个词。

试试这个:

选项 1:

<adaptive-icon
xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="#FFFFFF"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>

或选项 2:

<adaptive-icon
xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/white"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>

并添加到您的colors.xml

<color name="white">#FFFFFF</color>

关于java - 如何修复 ic_launcher_foregorund.xml 意外标记和未找到顶级元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56375390/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com