【问题标题】:New Project: Android resource compilation failed新项目:Android资源编译失败
【发布时间】:2018-11-14 16:54:37
【问题描述】:
**Error is Here:**

Android resource compilation failed
Output:  F:\UserApp\app\src\main\res\mipmap-anydpi-v26\ic_launcher.xml:1: error: not well-formed (invalid token).

Command: C:\Users\iAngkur\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.1-4818971-windows.jar\a5439741e2d1dbefbffc15295f5d15fb\aapt2-3.2.1-4818971-windows\aapt2.exe compile --legacy \
        -o \
        F:\UserApp\app\build\intermediates\res\merged\debug \
        F:\UserApp\app\src\main\res\mipmap-anydpi-v26\ic_launcher.xml
Daemon:  AAPT2 aapt2-3.2.1-4818971-windows Daemon #2

新建项目后,color.xml 文件有一些未知字符。然后我手动添加了这段代码。

<?xml version="1.0" encoding="utf-8" ?>
<resources>

    <color name="colorPrimary">#0a091b</color>
    <color name="colorPrimaryDark">#070716</color>
    <color name="colorAccent">#FF4081</color>

</resources>

依赖代码在这里。

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.google.firebase:firebase-auth:16.0.1'
    implementation 'com.google.firebase:firebase-database:16.0.1'
}

【问题讨论】:

  • 查看“ic_launcher.xml”
  • 你需要发布mipmap-anydpi-v26\ic_launcher.xml的内容

标签: android android-studio android-layout


【解决方案1】:

您的问题似乎与此文件有关app\src\main\res\mipmap-anydpi-v26\ic_launcher.xml:1

您可以尝试像这样更新它吗(将drawable更改为您自己的icon_launcher):

<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
  <background android:drawable="@android:color/black"/>
  <foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-03-02
    • 1970-01-01
    • 2019-04-06
    • 1970-01-01
    • 1970-01-01
    • 2019-03-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多