无法解决资源链接失败错误

时间:2018-11-01 09:27:33

标签: android attrs.xml

我遇到了以下错误,我不知道为什么会发生。我所做的只是添加标志 称为“ mon”,并尝试将其添加到xml的自定义视图中。除“ mon”以外的其他标志 好。此错误是什么意思?我希望收到您的来信。

Android resource linking failed
Output:  samp/app/src/main/res/layout/layout_mon.xml:2: error: 'mon' is incompatible with attribute mon_type (attr) flags [sol=1, dan=4, tin=2] [weak].
error: failed linking file resources.

Command: /Users/me/.gradle/caches/transforms-1/files-1.1/aapt2-3.2.1-4818971-osx.jar/0c6f710daca8a09e3/aapt2-3.2.1-4818971-osx/aapt2 link -I\
        /Users/me/Library/Android/sdk/platforms/android-26/android.jar\
        --manifest\
      /Users/me/Documents/samp/app/build/intermediates/instant_run_merged_manifests/_stagingDebug/process_stagingDebugManifest/instant-run/AndroidManifest.xml\
        -o\
        /Users/me/Documents/samp/app/build/intermediates/processed_res/_stagingDebug/process_stagingDebugResources/out/resources-_stagingDebug.ap_\
        -R\
        @/Users/me/Documents/samp/app/build/intermediates/incremental/process_stagingDebugResources/resources-list-for-resources-_stagingDebug.ap_.txt\
        --auto-add-overlay\
        --java\
        /Users/me/Documents/samp/app/build/generated/not_namespaced_r_class_sources/_stagingDebug/process_stagingDebugResources/r\
        --custom-package\
        jp.aeonretail.aeon.kidsrepublic\
        -0\
        apk\
        --preferred-density\
        xxhdpi\
        --output-text-symbols\
        /Users/me/Documents/samp/app/build/intermediates/symbols/_st/debug/R.txt\
        --no-version-vectors
Daemon:  AAPT2 aapt2-3.2.1-4818971-osx Daemon #0

//在attrs内部

<declare-styleable name="MonView">
    <attr name="mon_type">
        <flag name="sol" value="0x01"/>
        <flag name="dan" value="0x02"/>
        <flag name="tin" value="0x04"/>
        <flag name="mon" value="0x06"/>
    </attr>
</declare-styleable>

//视图

<?xml version="1.0" encoding="utf-8"?>
<example.MonView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/mon_id"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:mon_type="mon">
</example.MonView>

1 个答案:

答案 0 :(得分:0)

您缺少'>'标签

<example.MonView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/mon_id"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:mon_type="mon">

</example.MonView>