无法解决与Android中的属性错误不兼容 [英] Unable to solve incompatible with attribute error in android

查看:471
本文介绍了无法解决与Android中的属性错误不兼容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a following error andI have no clue why this is happening.All I did was add the flag called "mon" and tried to add it to the custom view in the xml. flags other than "mon" works well. What is the meaning of this error? I would love to hear from you.

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>

推荐答案

您声明了属性名称,但未指定输入类型 将您的attrs更改为

You declared the name of property but the type of input is not specified change your attrs to

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

希望它会有所帮助:)

这篇关于无法解决与Android中的属性错误不兼容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆